很抱歉这个愚蠢的问题,但我坚持因为这个问题,锚标签的宽度不起作用,基本上我想增加锚标签的高度,所以写在其中的文字不包裹
.filteredRestBody {
background: none repeat scroll 0 0 white;
border: 1px dotted #5bc0de;
border-top-left-radius: 23px;
box-shadow: 0 0 0 grey;
height: auto;
margin-left: -14%;
padding: 0 0 47px 8px;
position: relative;
top: 30px;
width: 115%;
}
.filterThumbnails {
background-position: 2px -19px;
background-repeat: repeat;
border-top-left-radius: 10%;
border-top-right-radius: 10%;
height: 300px;
margin-left: 4.3%;
margin-top: 50px;
width: 234px;
}
.restaurantThumbnailsTitle {
background: none repeat scroll 0 0 rgba(0, 0, 0, 0.6);
color: white;
font-size: 1.6em;
height: 95px;
margin-left: -14px;
position: relative;
top: 44.7%;
width: 114%;
}
.restaurantThumbnailsTitle > a {
color: white;
font-weight: bold;
}
.restaurantThumbnailsTitleText {
font-size: 1em;
font-weight: unset;
left: 0;
text-shadow: 1px 1px 0 red;
top: 0;
width: auto;
}
<div id="filteredRestBody" class="row filteredRestBody">
<div id="row1" class="row">
<div id="indianchilly" class="col-sm-4 filterThumbnails" style="background:url('images/yochinathumbbck.jpg')">
<img src="images/bestoffers.png">
<div id="discountNum">Discount 15%</div>
<div class="ratingsContainer">
<div id="restaurantThumbnailsTitle" class="restaurantThumbnailsTitle">
<a href="viewRestaurant.php?rest=yochina">Indian Chilly</a>
<p class="restaurantThumbnailsTitleText">chilled out chinese</p>
</div>
</div>
</div>
</div>
</div>
我尝试了很多东西,但只有通过增加filterThumbnails的宽度才得到的解决方案,我不想增加,请,任何人帮助我
提前致谢
答案 0 :(得分:3)
请参阅spec:
默认情况下,“的宽度强>
- 价值:&lt;长度&gt; | &LT;百分比&GT; |汽车|继承
- 初始:自动
- 适用于:所有元素,但未替换的内联元素,表格行和行组
- 继承:否
- 百分比:指包含块的宽度
- 媒体:视觉
- 计算值:指定的百分比或“自动”或绝对长度
a
元素是未替换的内联元素。所以width
属性不适用。
答案 1 :(得分:0)
标记是内联的,因此它不受宽度或高度的影响,将display:inline-block;
添加到其css中,然后您就可以对其进行调整。
答案 2 :(得分:0)
内联元素的宽度不会改变。您需要将该锚点设为块或内联块,请参见此处(给它一个绿色背景,以便您可以看到它有多宽):
.filteredRestBody {
background: none repeat scroll 0 0 white;
border: 1px dotted #5bc0de;
border-top-left-radius: 23px;
box-shadow: 0 0 0 grey;
height: auto;
padding: 0 0 47px 8px;
position: relative;
top: 30px;
width: 115%;
}
.filterThumbnails {
background-position: 2px -19px;
background-repeat: repeat;
border-top-left-radius: 10%;
border-top-right-radius: 10%;
height: 300px;
margin-left: 4.3%;
margin-top: 50px;
width: 234px;
}
.restaurantThumbnailsTitle {
background: none repeat scroll 0 0 rgba(0, 0, 0, 0.6);
color: white;
font-size: 1.6em;
height: 95px;
margin-left: -14px;
position: relative;
top: 44.7%;
width: 114%;
}
.restaurantThumbnailsTitle a {
display: block;
background-color: green;
}
.restaurantThumbnailsTitle a:hover {
background-color: white;
}
&#13;
<div id="filteredRestBody" class="row filteredRestBody">
<div id="row1" class="row">
<div id="indianchilly" class="col-sm-4 filterThumbnails" style="background:url('images/yochinathumbbck.jpg')">
<img src="images/bestoffers.png">
<div id="discountNum">Discount 15%</div>
<div class="ratingsContainer">
<div id="restaurantThumbnailsTitle" class="restaurantThumbnailsTitle">
<a href="viewRestaurant.php?rest=yochina">Indian Chilly</a>
<p class="restaurantThumbnailsTitleText">chilled out chinese</p>
</div>
</div>
</div>
</div>
</div>
&#13;