[英]HTML, CSS place div at the left instead of right of relative element
我有以下代碼片段:
#wrap { position: relative; width: auto; background: silver; border: 1px solid grey; } #text { position: absolute; width: 25%; right: 0; top: 0; bottom: 0; background: black; opacity: 0.5; filter: alpha(opacity=50); }
<div> <div id="wrap"> <img class="fit-img" src="~/Content/img/Assets/image.jpg"> <div id="text"></div> </div> </div>
我需要將帶有ID text
的DIV放在包裝內容的左側,而不是右側。 有小費嗎?
只需right: 0;
並用left: 0;
替換它left: 0;
在這里:
#text {
position: absolute;
width: 25%;
left: 0;
top: 0;
bottom: 0;
background: black;
opacity: 0.5;
filter: alpha(opacity=50);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.