简体   繁体   中英

HTML, CSS place div at the left instead of right of relative element

I have this code snippet:

 #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> 

I need to place the DIV with the ID text at the left, not the right side of wrapped content. Any tips?

Just erase right: 0; and replace it with left: 0; in here:

#text {
  position: absolute;
  width: 25%;
  left: 0;
  top: 0;
  bottom: 0;
  background: black;
  opacity: 0.5;
  filter: alpha(opacity=50);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM