【发布时间】:2020-09-02 19:16:16
【问题描述】:
我怎样才能在图像上加上固定位置的文字?并且图像可以通过改变浏览器的视图大小来调整大小,我想要的文本和图像的位置是这样的:
我知道使用position:absolute,但也希望组到宽度的中心
html:
.figure {
position: relative;
display: inline-block;
max-width: 100%;
}
.figure .figcaption {
width: 100%;
height: 0;
font-size: 25px;
line-height: 0;
color: white;
position:absolute;
top: 50%;
z-index: 1;
}
.figure img {
display:block;
max-width: 100%;
}
#subscribe {
display: flex;
position: relative;
margin: 0;
padding: 0;
align-items: center;
}
input {
-webkit-appearance: none;
outline: none;
border: 0;
}
input[type="email"] {
position: relative;
width: 50%;
height: 40px;
border-radius: 20px;
padding-left: 20px;
}
<div class="figure">
<div class="figcaption">
<div class="slogen">
<p>SLOGEN1</p>
<p>SLOGEN2</p>
<p>SLOGEN3</p>
</div>
<div class="content">
<p>CONTENT1</p>
<p>CONTENT2</p>
<p>CONTENT3</p>
<p>CONTENT4</p>
</div>
<div id="subscribe">
<input type="email" placeholder="enter your email here">
</div>
</div>
<img src="http://s4.favim.com/orig/50/beautiful-city-light-night-street-Favim.com-460323.jpg"/>
</div>
代码在这里:
https://codepen.io/jevonsdone/pen/xxVXzGv
谢谢!
【问题讨论】:
-
我完全不明白。您是否希望您的标题位于图片的左下角并且即使在调整大小时也保留在那里?
-
我希望图像底角的文本并固定,只有图像可以在视图更改时调整大小。并且文本和图像之间的位置不会移动
-
codepen.io/frangaren/pen/wvGrXzp 是你想要的吗?
-
这段代码来自我,但我希望文本在正确的位置与图像和固定
-
为什么不应用一个margin-left: 50px;在你的形象上?
标签: html css position resizable