首页 \ 问答 \ 中心div的可变宽度,左右固定div具有透明圆角图像(Variable width for the center div with fixed left & right div having transparent rounded corners images)

中心div的可变宽度,左右固定div具有透明圆角图像(Variable width for the center div with fixed left & right div having transparent rounded corners images)

我正试图展示

  • 一个可变宽度的弹出窗口
  • 将具有透明边缘的圆角以匹配背景颜色。

首先我认为这是一个简单的圆角标记,但问题是半径的透明背景和弹出窗口的可变宽度。

<css>
    .c-dialog-rc-tl, .c-dialog-rc-tc, .c-dialog-rc-tr,
    .c-dialog-rc-bl, .c-dialog-rc-bc, .c-dialog-rc-br {
        background-color: none;
        height: 10px;
    }
    .c-dialog-rc-tl, .c-dialog-rc-bl { 
        float:left;
        width:20px;
    }
    .c-dialog-rc-tl {
        background-position: 0 -30px;
        z-index:1005;
        position:absolute;
    }
    .c-dialog-rc-bl {
        background-position: 0 -43px;
        z-index:1004;
        position:absolute;
    }
</css>

<div class="c-dialog-rc-top">
    <div class="c-dialog-image c-dialog-rc-tl"></div>
    <div class="c-dialog-image c-dialog-rc-tc"></div>
    <div class="c-dialog-image c-dialog-rc-tr"></div>
</div>

我尝试了这个答案的回复,但没有奏效。 请参阅jsfiddle的代码。

如果问题不明确,我会尝试提供尽可能多的信息,但请不要低估或删除问题。

有没有人解决过这种问题,或者知道更好的div布局还是css会提出这样的要求?

提前致谢。


I'm trying to display

  • a variable width popup
  • that will have rounded corners with transparent edges to match the background color.

First I thought it was a simple rounded corner markup, but then the problem was with transparent background for the radius and the variable width of the popup.

<css>
    .c-dialog-rc-tl, .c-dialog-rc-tc, .c-dialog-rc-tr,
    .c-dialog-rc-bl, .c-dialog-rc-bc, .c-dialog-rc-br {
        background-color: none;
        height: 10px;
    }
    .c-dialog-rc-tl, .c-dialog-rc-bl { 
        float:left;
        width:20px;
    }
    .c-dialog-rc-tl {
        background-position: 0 -30px;
        z-index:1005;
        position:absolute;
    }
    .c-dialog-rc-bl {
        background-position: 0 -43px;
        z-index:1004;
        position:absolute;
    }
</css>

<div class="c-dialog-rc-top">
    <div class="c-dialog-image c-dialog-rc-tl"></div>
    <div class="c-dialog-image c-dialog-rc-tc"></div>
    <div class="c-dialog-image c-dialog-rc-tr"></div>
</div>

I tried the replies of this answer but didn't work. Please see the code at jsfiddle.

I'll try to provide as much as information if the question is not clear but please don't downvote or delete the question.

Has anybody solved this kind of problem, or know a better div layout or a css that will render such a requirement ?

Thanks in advance.


原文:https://stackoverflow.com/questions/18640792
更新时间:2023-06-12 17:06

最满意答案

是的,你可以安装LinqKit nuget包并使用它的PredicateBuilder (如果出于任何原因你不能\不想安装第三方包 - 你可以自己实现类似的功能)。 使用PredicateBuilder你可以这样做:

// start with false, because building OR expression
// and false OR something is the same as just something
var condition = PredicateBuilder.New<Product>(false);
if (userSettings.DisplayYesterday)
    condition = condition.Or(x => DbFunctions.TruncateTime(x.ListedTime) == yesterday);
if (userSettings.DisplayToday)
    condition = condition.Or(x => DbFunctions.TruncateTime(x.ListedTime) == today);
if (userSettings.DisplayTomorrow)
    condition = condition.Or(x => DbFunctions.TruncateTime(x.ListedTime) == tomorrow);
query = query.Where(condition);

如果你用AND加入多个条件(而不像这里那样是OR),你不需要谓词构建器,只需链接调用:

if (someCondition)
    query = query.Where(x => x.SomeField == someValue);
if (anotherCondition)
    query = query.Where(x => x.SomeAnotherField == someAnotherValue);

Yes, you can install LinqKit nuget package and use its PredicateBuilder (if for whatever reason you cannot\don't want to install third party package - you can implement similar functionality yourself). With PredicateBuilder you can do it like this:

// start with false, because building OR expression
// and false OR something is the same as just something
var condition = PredicateBuilder.New<Product>(false);
if (userSettings.DisplayYesterday)
    condition = condition.Or(x => DbFunctions.TruncateTime(x.ListedTime) == yesterday);
if (userSettings.DisplayToday)
    condition = condition.Or(x => DbFunctions.TruncateTime(x.ListedTime) == today);
if (userSettings.DisplayTomorrow)
    condition = condition.Or(x => DbFunctions.TruncateTime(x.ListedTime) == tomorrow);
query = query.Where(condition);

If you join multiple conditions with AND (and not OR like here), you don't need predicate builder, just chain Where calls:

if (someCondition)
    query = query.Where(x => x.SomeField == someValue);
if (anotherCondition)
    query = query.Where(x => x.SomeAnotherField == someAnotherValue);

相关问答

更多
  • 是否危险(为了可读性,可维护性或任何其他原因)混合查询和扩展语法? 我看到的最大危险是在代码中增加“惊喜”,特别是当其他开发人员查看时。 从编译的角度来看,查询语法直接转换为扩展方法调用,所以这里不一定存在技术问题。 但是,这可能会增加额外的方法调用,乍一看,很多开发人员都不会这么做。 这可能会导致潜在的可维护性问题。 话虽如此,如果做得有节制,并且有充分的理由,我认为混合语法并不存在真正的问题。 这实际上非常普遍 - 例如,如果你想用查询语法编写,但需要完全评估,它通常包含在添加了.ToList()的圆括 ...
  • 简单地去: string lambdaSyntax = query.Expression.ToString(); 与LINQPad相比的缺点是结果是格式化的所有行。 Simply go: string lambdaSyntax = query.Expression.ToString(); The disadvantage compared to LINQPad is that the result is formatted all one line.
  • 没有区别。 您的第一个版本(查询语言) 在 “真实”编译之前被词法翻译成第二个版本(方法语法)。 查询语言只是语法糖并转换为方法调用。 然后编译这些调用(如果可能的话 - 翻译本身并不关心结果的正确性,例如,如果People.Join甚至是有效的C#,并且在People可能的任何地方都有这样的Join方法)。 可能有一点不同之处在于,此转换使用显式Select调用而不是Join方法的resultSelector参数,但即使这样也不会对性能产生显着影响。 Jon Skeet 撰写的这篇文章帮助我理解了从查询语 ...
  • 据我所知,该语法不是“正常”的C# 是的,从C#3开始。 所以如果我没有包含System.Linq,上面的行没有任何意义 是的,它会。 它仍然会被编译器有效地转换为: var queryLondonCustomers = customers.Where(cust => cust.City == "London"); (缺少Select调用是因为你直接选择范围变量,而不是对它进行一些投影。) 如果该代码已经编译(例如,由于customers中的Where成员,或者由于其类型上的另一个扩展方法),那么查询表达 ...
  • 我相信你需要的是: var statements = from itemsGroup in itemGroups from linkedItemStatements in //here goes a nested query (from linkedItem in itemsGroup.LinkedItems let table = GetTable(linkedItem, targetTable) select ...
  • 连接点是在两个独立的数据源中查找匹配元素。 换句话说,连接右侧的元素不能依赖于连接的“当前”左侧的元素。 所以当你扁平化时你不能加入。 你只是为了有效地隔离“给定的两个表格,找出差异”部分,然后将这些结果展平。 我相信这会做你想做的事情: var changes = from table1 in db1 let table2 = ReadTable(table1.Name) from change in (from ...
  • 这与您的任何代码无关 - 在参数列表中不允许使用and运算符。 至于为什么 ,你必须问核心团队,但IMO最明显的可能性是它的存在理由(具有极低的优先级)在参数列表中不起作用。 This has nothing to do with any of your code — the and operator just isn't allowed in an argument list. As for why, you'd have to ask the Core team, but the most obviou ...
  • 请试试这个: var info = from a in tblItems group a by new { a.ExpiryDate.Year, a.ExpiryDate.Month } into bca select new ConsolidatedData() { MonthField = ...
  • 是的,你可以安装LinqKit nuget包并使用它的PredicateBuilder (如果出于任何原因你不能\不想安装第三方包 - 你可以自己实现类似的功能)。 使用PredicateBuilder你可以这样做: // start with false, because building OR expression // and false OR something is the same as just something var condition = PredicateBuilder.New
  • 这个问题有多个步骤: 将列表“名称”分隔为列表L列表 执行列表LxL的笛卡尔积,其中列表是不同的 从每对列表的笛卡尔积中得出 合并所有结果。 这是一个实现: var NameLists = keys.GroupBy(k => k.Name); var NameListPairs = from first in NameLists from second in NameLists where first != second se ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)