我有图像,我应该制作图片并将文字也放在按钮上,如图所示,我想把文字放在黄色按钮中也替换所有文字
所有文字都应该像
HTML:
<div style="width: 450px; display: inline-block; vertical-align: top">
<table align="left" cellspacing="0" cellpadding="0">
<tr>
<td>
<!-- ^Текст --> <span style="display: block; overflow: hidden; width: 390px; height: 400px; margin-left:10px">
<div class="image-wrapper"><img src="http://i.imgur.com/dbaQzUC.png" alt="" style="width: 250px" class="fluid-img"> <a href="http://icome.su">Подробнее</a></div>
</span>
<!-- $Текст -->
</td>
</tr>
</table>
</div>
CSS:
.image-wrapper { position: relative; }
.image-wrapper a { position: absolute; left: 235; top: 340; padding: 10px;
color: black; margin: 5px; }
.image-wrapper2 a { position: absolute;left: 235; top: 340; padding: 10px;
color: black; margin: 5px;}
.fluid-img {
height:auto !important;
max-width:870px !important;
width: 100% !important;
min-width: 90% !important;
}
.fluid-img2{
height:auto !important;
max-width:800px !important;
width: 100% !important;
margin-top:-100px
}
这是我的fiddle
答案 0 :(得分:2)
我试图重现你的图像(没有确切的尺寸)。看看:
.img-container {
position: relative;
width: 250px;
height: 350px;
-moz-border-radius: 20px;
-webkit-border-radius: 20px;
border-radius: 20px;
overflow: hidden;
}
.img-container .discount,
.img-container .desc,
.img-container img,
.img-container p,
.img-container span,
.img-container a {
position: absolute;
display: block;
}
.img-container .discount {
top: 10px;
left: 10px;
width: 50px;
height: 50px;
background-color: red;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
border-radius: 50px;
color: #fff;
font-style: 20px;
font-weight: bold;
z-index: 1;
}
.img-container .discount span {
top: 50%;
left: 50%;
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.img-container .desc {
bottom: 0;
left: 0;
width: 100%;
height: 110px;
background-color: rgba(255, 255, 255, 0.4);
text-align: center;
}
.img-container .desc a {
text-decoration: none;
color: white;
font-weight: bold;
padding: 3px 6px;
text-transform: uppercase;
background-color: orange;
border: none;
bottom: 10px;
right: 15px;
}
&#13;
<div class="img-container">
<div class="discount">
<span>50%</span>
</div>
<img src="//lorempicsum.com/futurama/250/350/2" alt="" />
<div class="desc">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quam natus minus corporis exercitationem.</p>
<a href="">Enter</a>>
</div>
</div>
&#13;
答案 1 :(得分:1)
这样的事情:http://jsfiddle.net/EgLKV/3/
通过使用position:absolute和z-index将文本放在图像上来完成。
这是HTML:
<div id="container">
<img id="image" src="image.jpg"/>
<p id="text">
<a href="#" i="button">Visit</button>
</p>
</div>
这里是CSS:
#container
{
height:400px;
width:400px;
position:relative;
}
#image
{
position:absolute;
left:0;
top:0;
}
#text
{
z-index:100;
position:absolute;
color:white;
font-size:24px;
font-weight:bold;
left:150px;
top:350px;
}
#button
{
height:40px;
width:100px;
background-color:orange;
}
答案 2 :(得分:1)
这样的东西?
HTML:
<div class="item">
<img src="image.jpg" alt="Alternative text" />
<p class="discount">50%</p>
<p class="desc">This is a description text</p>
</div>
CSS:
* { margin: 0; padding: 0; }
.item {
width: 400px;
height: 400px;
position: relative;
border-radius: 25px;
overflow: hidden;
}
.item img {
max-width: 100%;
max-height: 100%;
}
.discount {
background: #EE6666;
width: 75px;
height: 75px;
display: block;
position: absolute;
top: 10px;
left: 10px;
border-radius: 50%;
font-size: 2em;
line-height: 75px;
vertical-align: middle;
text-align: center;
color: white;
-webkit-box-shadow: 5px 5px 5px 0px rgba(50, 50, 50, 0.75);
-moz-box-shadow: 5px 5px 5px 0px rgba(50, 50, 50, 0.75);
box-shadow: 5px 5px 5px 0px rgba(50, 50, 50, 0.75);
}
.desc {
position: absolute;
left: 0;
right: 0;
bottom: 0;
padding: 1em;
background: rgb(255,255,255);
background: rgba(255,255,255,.6);
}