【发布时间】:2016-09-28 20:24:32
【问题描述】:
我需要使用 css 创建下面的图像。
但这就是我得到的
每次您将鼠标悬停在图像上时,叠加层都会消失,我已经这样做了。
但是中间的图像包含带有椭圆的文本(立即购买),我无法正确定位椭圆。
这是我的小提琴:
https://jsfiddle.net/9f6xat3f/1/
这是我拥有的一些 CSS:
.trending-button1{
border-radius: 25px;
border: 3px solid #fff;
padding: 20px;
width: 200px;
height: 50px;
}
/*banner overlay*/
div.homepage-popular-categories {
position: relative;
display: inline-block;
}
div.homepage-popular-categories p {
margin: 0;
/*display: block;*/
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
color: #eeeeec;
background: rgba(0,0,0,0.5);
transition: opacity 0.5s;
opacity: 1;
text-align: center;
font-family: sans-serif;
font-size: 1.2em;
font-weight: bold;
}
div.homepage-popular-categories p:before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
}
div.homepage-popular-categories p:hover {
background: rgba(0,0,0,0);
}
/*end banner overlay*/
.new-arrivals{
background:url('https://s-media-cache-ak0.pinimg.com/originals/4f/a9/d1/4fa9d18c567a8c5a05997a9773685361.jpg') no-repeat;
width:313px;
height:313px;
}
.trending{
background:url('http://socialmediaoutcomes.com/go/wp-content/uploads/2013/08/successful-business-people-smiling.jpg') no-repeat;
width:313px;
height:313px;
}
.shop-by-goal{
background:url('https://brianpshea.files.wordpress.com/2013/06/4234255-group-of-business-people-smiling-together-in-an-office.jpg') no-repeat;
width:313px;
height:313px;
}
.strov-3-banners{
margin-top:15px;
text-align: center;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
-o-box-sizing: border-box;
box-sizing: border-box;
padding:10px 0;
}
如何正确定位椭圆?
【问题讨论】:
-
你要找的是如何垂直对齐多行文本。
-
“圆形椭圆”是矛盾的。像一个“方形矩形”
-
@j08691 你说得对,没注意。
-
您的身高规则中缺少“px”
-
@JordanBarber 我注意到了,我修好了。但它仍然不会居中,并且覆盖也关闭了。 jsfiddle.net/9f6xat3f/1