【发布时间】:2015-08-10 21:10:55
【问题描述】:
使用css时,如何指定嵌套类。
这是我的html 代码:
<div class="box1">
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">Collapsable</h3>
<div class="box-tools pull-right">
<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</div><!-- /.box-tools -->
</div><!-- /.box-header -->
<div class="box-body">
<p><i class="fa fa-phone"></i><span style=""> Phone : 0800 000 000</span></p>
<p><i class="fa fa-home"></i><span style=""> Web : http://www.example.com</span></p>
<p><i class="fa fa-map-marker"></i><span style=""> Map : example map address</span></p>
<p><i class="fa fa-envelope"></i><span style=""> Email : example@address.com</span></p>
</div><!-- /.box-body -->
</div><!-- /.box -->
</div>
此css 代码适用于页面上的所有html:
<style type="text/css">
i{width: 30px;}
</style>
如何在box1 box-body 类中指定i class?
这是我尝试过的代码:
<style type="text/css">
box1 box-body i{width: 30px;}
</style>
提前致谢。
【问题讨论】:
-
你需要在你的课堂陈述中加上句号/句号
.box1 .box-body i{width: 30px;} -
看看这个关于选择器的精彩教程:code.tutsplus.com/tutorials/…
标签: html css class nested-class