我正在使用下面的HTML显示标签列表(我通过专注于最长的列表来简化它,因为这是导致我的问题的那个)。如何进行制作,以便div
包含ul
的{{1}}根据ul
的长度自动扩展到其高度。 CSS
低于HTML
:
<div class="col-lg-offset-2 col-lg-8">
<section class="tabs">
<h2 class="centered">SAMPLE MENU</h2>
<input id="tab-1" type="radio" name="radio-set" class="tab-selector-1" checked="checked" />
<label for="tab-1" class="tab-label-1">Casual Eating</label>
<input id="tab-2" type="radio" name="radio-set" class="tab-selector-2" />
<label for="tab-2" class="tab-label-2">Dining</label>
<input id="tab-3" type="radio" name="radio-set" class="tab-selector-3" />
<label for="tab-3" class="tab-label-3">Afternoon Tea</label>
<input id="tab-4" type="radio" name="radio-set" class="tab-selector-4" />
<label for="tab-4" class="tab-label-4">Desserts</label>
<div class="clear-shadow"></div>
<div class="content">
<div class="content-2">
<ul class="menu_items">
<li>
<h3>Wild Boar Bons</h3>
<p>wensleydale wild boar, pickled mushrooms & quince</p>
</li>
<li>
<h3>Tangled Tiger Prawns</h3>
<p>chilli & garlic prawns, straw pastry, spiced coconut broth</p>
</li>
<li>
<h3>Wood Pigeon Nest</h3>
<p>local wood pigeon, potato & parsnip nest, foraged fruit</p>
</li>
<li>
<h3>Avocado Mango Burratta</h3>
<p>buffalo mozzarella, alfonso mango, citrus rye toast</p>
</li>
<li>
<h3>Seared Black Salmon</h3>
<p>cucumber salad, soy, ginger & mirin</p>
</li>
<li>
<h3>Rose Veal Rib</h3>
<p>aged veal chop, rosemary desiree potato & shallots</p>
<li>
<h3>Crispy Rabbit Cassoulet</h3>
<p>fried leg, loin, chorizo cassoulet & celeriac slaw</p>
</li>
<li>
<h3>Morel Butter Turbot</h3>
<p>turbot loin poached in morel butter, capers & samphire</p>
</li>
<li>
<h3>Wild Garlic Raviolo</h3>
<p>green herb pasta, goats cheese, confit shallots</p>
</li>
<li>
<h3>Pink Lady Pig</h3>
<p>belly & loin, king scallop & apple salad</p>
</li>
<li>
<h3>Pecan Maple Goose</h3>
<p>wild goose, streaky bacon, roast swede & chesnuts</p>
</li>
<li>
<h3>Lobster Fennel Pie</h3>
<p>whole lobster tail, saffron mash & baby fennel</p>
</li>
<li>
<h3>Girolle Truffle Brioche</h3>
<p>girolles, quails eggs, asparagus, black truffle & toasted brioche</p>
</li>
<li>
<h3>Pan Fried Fillet</h3>
<p>oxtail fritter ,smoked garlic& sirloin butter, roast onion</p>
</li>
</ul>
</div>
</div>
</section>
</div>
上述代码的CSS:
.menu_wrapper {
background: url(../img/bg/light_cream_bg.jpg);
}
.tabs {
background: url("http://fmkcatering.com/wp-content/themes/fmk/images/grey-bg.jpg") repeat scroll 0 0 rgba(0, 0, 0, 0);
position: relative;
margin: 40px auto;
width: 750px;
}
.tabs input {
position: absolute;
z-index: auto;
width: 100%;
height: 40px;
left: 0px;
top: 38px;
opacity: 0;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
cursor: pointer;
}
.tabs label {
font-size: 15px;
line-height: 40px;
height: 40px;
position: relative;
padding: 0 20px;
float: left;
display: block;
width: 187px;
color: #385c5b;
letter-spacing: 1px;
text-transform: uppercase;
font-weight: bold;
text-align: center;
text-shadow: 1px 1px 1px rgba(255,255,255,0.3);
border-radius: 3px 3px 0 0;
}
.tabs label:after {
content: '';
position: absolute;
bottom: -2px;
left: 0;
width: 100%;
height: 2px;
display: block;
}
.tabs input:hover + label {
color: #FFF;
border: 1px solid #F90;
background-color: #CCC;
}
.tabs label:first-of-type {
z-index: 4;
}
.tab-label-2 {
z-index: 3;
}
.tab-label-3 {
z-index: 2;
}
.tab-label-4 {
z-index: 1;
}
.tabs input:checked + label {
z-index: 6;
}
.clear-shadow {
clear: both;
}
.content {
position: relative;
width: 100%;
height: 370px;
z-index: 5;
border-radius: 0 3px 3px 3px;
}
.content div {
position: absolute;
top: 0;
left: 0;
padding: 10px 40px;
z-index: 1;
opacity: 0;
-webkit-transition: opacity linear 0.1s;
-moz-transition: opacity linear 0.1s;
-o-transition: opacity linear 0.1s;
-ms-transition: opacity linear 0.1s;
transition: opacity linear 0.1s;
}
.tabs input.tab-selector-1:checked ~ .content .content-1, .tabs input.tab-selector-2:checked ~ .content .content-2, .tabs input.tab-selector-3:checked ~ .content .content-3, .tabs input.tab-selector-4:checked ~ .content .content-4 {
z-index: 100;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=100);
opacity: 1;
-webkit-transition: opacity ease-out 0.2s 0.1s;
-moz-transition: opacity ease-out 0.2s 0.1s;
-o-transition: opacity ease-out 0.2s 0.1s;
-ms-transition: opacity ease-out 0.2s 0.1s;
transition: opacity ease-out 0.2s 0.1s;
}
.content div h2, .content div h3 {
color: #398080;
}
.content div p {
font-size: 14px;
line-height: 22px;
font-style: italic;
text-align: left;
margin: 0;
color: #777;
font-family: Cambria, Georgia, serif;
text-align: center;
}
.menu_items {
list-style: none outside none !important;
width: 700px;
margin: 0;
padding: 0;
text-align: left;
}
.menu_items li {
float: left;
width: 340px;
}
.menu_items li h3 {
font-size: 15px;
font-size: 15px;
margin-bottom: 5px;
text-align: center;
}
这是小提琴:
答案 0 :(得分:0)
我已经更新了示例(抱歉,没有意识到其他人不会再看到原始代码 - 我第一次使用jsfiddle)。
我不得不做各种改变:
最重要的是为&#34; .content添加了一条规则:&#34; (这通常用于在CSS中定义clearfix类,并在适当的元素上使用它
.content:after { 内容:&#34; &#34 ;; 显示:块; font-size:0; 身高:0; 明确:两者; 能见度:隐藏; }
现在背景延伸到列表的底部
答案 1 :(得分:0)
我会在你的css中改变你的3件事:
这些元素的更新css将是:
.content {
position: relative;
width: 100%;
z-index: 5;
border-radius: 0 3px 3px 3px;
}
.content div {
padding: 10px 40px;
z-index: 1;
opacity: 0;
-webkit-transition: opacity linear 0.1s;
-moz-transition: opacity linear 0.1s;
-o-transition: opacity linear 0.1s;
-ms-transition: opacity linear 0.1s;
transition: opacity linear 0.1s;
}
.menu_items li{
display:inline-block;
width:340px;
}