- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个无序列表,其中包含 3 个列表项(在我的示例中表示为 3 个绿色框)。每个框都有一个图像和 3 个 div(标题、位置、价格)。我只关心每个框的标题 div。
如果标题足够长以致于产生 2 行,我希望顶行始终比底线短。我的演示站点看到了here显示框 1 和 2 的设置错误,框 #3 显示正确的设置。
我遇到了麻烦...这可能需要js来判断行长,然后把底线设置得更长一些。屏幕分辨率可能会发挥作用,但我不能使线条在不同的屏幕尺寸上保持一致吗?
这是列表项之一,我对 div“titlebox”感兴趣:
<li class="list__item">
<figure class="list__item__inner">
<p class="vignette" style="background-image:url(http://www.ht-real-estate.com/template/ht2014/images/landscape/05.jpg)"></p>
<div class="titlebox">This line is longer than this line</div>
<div class="locationbox">Location</div>
<div class="pricebox">Price</div>
</li>
任何帮助都很棒,谢谢!!
附上截图:
最佳答案
这是一个 JS 解决方案,在大多数情况下可能对您有用(我说大多数情况是因为文本字符可以有不同的宽度)。它基本上将您的句子分成两行,并动态插入 <br>
。标签。代码中的注释:
$(".titlebox").each(function(){
var len = $(this).text().length,
words = $(this).text().split(" "),
line1 = [],
line2 = [],
html = "";
// iterate through each word in the title
$.each(words, function(i,word){
// if line 1's current length plus the length of this word
// is less than half the total characters, add word to line 1
// else add to line 2
// (check index of word to maintain order)
if((line1.join(" ")+" "+word).length < (len/2) && (i == line1.length)){
line1.push(word);
} else {
line2.push(word);
}
});
// concatenate the results with a '<br>' separating the lines
html = line1.join(" ")+"<br>"+line2.join(" ");
// replace the .titlebox content with this new html string
$(this).html(html);
});
关于javascript - 如何使顶线短于底线(在div内),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28201147/
一直在使用Vim多年来,一直以来我都接受了bright and distracting the visual bell曾是。最近有人给我看Emacs visual bell ,它只闪烁屏幕的顶行和底行
如何删除 UITableViewController 中的 UISearchBar 底线? 也可以应用 Swift 解决方案。 这是我的 VC 代码: NavigationController.Nav
我有一个 Activity ,我在其中将数据 bundle 到另一个 Activity 。有了这些数据,我还 bundle 了一个自定义颜色,我希望在 Activity 2 中显示 EditText
我有一个应用有时需要其导航栏才能与内容融为一体。 有谁知道如何摆脱这个烦人的小酒吧或改变它的颜色? 在下图的情况下,我说的是“ Root View Controller ”下方的 1px 高度线 最佳
如何删除DataRepeater控件中数据控件项的底部边框线: 最佳答案 您在 DataRepeater 中看到的分隔符项目之间的控制,是非客户区的绘图DataRepeaterItem控制。 你可以找
.segment-button-indicator { -ms-flex-item-align: end; align-self: flex-end;
我是一名优秀的程序员,十分优秀!