如何在CSS中单独定位此HTML代码?
16lz
2021-01-22
I have two sets of text that need to be inline with each other but at the moment one is placed higher than the other. The two sets of text share the same CSS code so when I edit it, both are affected. However, I would like to target only one of the text; Is there a way of doing this?
我有两组文本需要彼此内联,但目前一个文本放在另一个上面。这两组文本共享相同的CSS代码,因此当我编辑它时,两者都会受到影响。但是,我想只针对其中一个文本;有办法做到这一点吗?
Here is the HTML and CSS:
这是HTML和CSS:
<div id="mi-slider" class="mi-slider">
<?
$result = $mysqli->query("SELECT * FROM stock");
while($obj = $result->fetch_object())
{
if($obj->id&1)
echo "<ul>";
?>
<li class="<?=$obj->orientation=='landscape'?'landscape':'portrait'?>" id="list">
<a href="#"><img src="./img/<?=$obj->description=='unframed'?$obj->poster_no:$obj->poster_no.'_frame'?>.jpg" alt=""></a>
<h4><?= $obj->description=="unframed"?"Unframed Poster - 750mm x 500mm":"Framed Poster - 790mm x 540mm"?><br />£<?=$obj->price?> each</h4>
</li>
The CSS code:
CSS代码:
.mi-slider ul li h4 {
display: inline-block;
font-family: HelveticaNeueRegular;
font-weight: 100;
font-size: 12px;
color: #a34235;
padding: 0 0 0;
text-align: left;
margin-top: 20px;
margin-left: 10px;
float: left;
}
3 个解决方案
#1
1
If you want to target the second list items H4, you can use the nth-child selector, as below:
如果要定位第二个列表项H4,可以使用第n个子选择器,如下所示:
.mi-slider ul li:nth-child(2) h4
{ your css }
更多相关文章
- 10段实用的HTML5代码
- 如何将添加到ajax html编辑器的文本保存为html文档?
- 如何将每个单词都包含在一个span中,同时保留文本格式
- 文本输入占位符不在IE和Firefox中显示
- 用JavaScript实现两种功能:1、切换全选/全不选文字;2、根据选中个
- HTML5+学习笔记2-------边看代码边研究貌似还是有点问题...还在
- PHP代码在不需要时在Javascript中自动运行[重复]
- 如何控制html代码中DL标签的颜色?
- php 读取文本文件