文本在响应式设计中的位置[关闭]

问题描述 投票:0回答:1

我有一个响应式布局,背景居中,没有指定宽度属性。现在我想要一个在背景图像内对齐的div。

像这样:

回应#Jasper Seinhorst ..

这是问题..它漂浮在div之外

HTML =>

<div class="view_banner" style="background: url({$header.headerimg}) center 0 no-repeat;">
{if $header.copyright}
<div class="copyright">Courtesy Cree Europe</div>
{/if}
</div>

CSS =>

.view_banner {position: relative; width: 100%; height:476px;}
 .copyright{position: absolute; right: 0; bottom: 0; font-size: 16px; color: black;}
html css responsive-design position
1个回答
2
投票

使用背景图像添加相对于div的位置。使用文本向div添加绝对位置。

#image_with_bg {
  position: relative;
  width: 200px; /* remove this */
  height: 50px; /* remove this */
  background-color: #ff0000;
}

#overlay_text {
  position: absolute;
  right: 0;
  bottom: 0;
  background-color: #fff;
}
<div id="image_with_bg">
  <div id="overlay_text">Text goes here</div>  
</div>
© www.soinside.com 2019 - 2024. All rights reserved.