Html 用鼠标悬停将图像并排对齐
您必须将Html 用鼠标悬停将图像并排对齐,html,css,Html,Css,您必须将float属性添加到container2选择器中。请检查下面的css规则 .container2 { position: relative; width: 250px; } .image { display: block; width: 250px; height: 300px; height: auto; margin: 17%; border-top-left-radius: 30px; border-top-right-radius: 30px
float
属性添加到container2
选择器中。请检查下面的css规则
.container2 {
position: relative;
width: 250px;
}
.image {
display: block;
width: 250px;
height: 300px;
height: auto;
margin: 17%;
border-top-left-radius: 30px;
border-top-right-radius: 30px;
}
.overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: #4CAF50;
overflow: hidden;
width: 100%;
height: 0;
transition: .5s ease;
margin-left: 17%;
border-top-left-radius: 70px;
border-top-right-radius: 70px;
pointer-events: none
}
.container2:hover .overlay {
height: 85%;
}
.text {
color: white;
font-size: 15px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
.overlay2 {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: #4CAF50;
overflow: hidden;
width: 100%;
height: 0;
transition: .5s ease;
margin-left: 17%;
border-top-left-radius: 70px;
border-top-right-radius: 70px;
pointer-events: none
}
.container2:hover .overlay2 {
height: 85%;
}
.overlay3 {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: #4CAF50;
overflow: hidden;
width: 100%;
height: 0;
transition: .5s ease;
margin-left: 17%;
border-top-left-radius: 70px;
border-top-right-radius: 70px;
pointer-events: none
}
.container2:hover .overlay3 {
height: 85%;
}
您必须将
float
属性添加到container2
选择器中。请检查下面的css规则
.container2 {
position: relative;
width: 250px;
}
.image {
display: block;
width: 250px;
height: 300px;
height: auto;
margin: 17%;
border-top-left-radius: 30px;
border-top-right-radius: 30px;
}
.overlay {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: #4CAF50;
overflow: hidden;
width: 100%;
height: 0;
transition: .5s ease;
margin-left: 17%;
border-top-left-radius: 70px;
border-top-right-radius: 70px;
pointer-events: none
}
.container2:hover .overlay {
height: 85%;
}
.text {
color: white;
font-size: 15px;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
.overlay2 {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: #4CAF50;
overflow: hidden;
width: 100%;
height: 0;
transition: .5s ease;
margin-left: 17%;
border-top-left-radius: 70px;
border-top-right-radius: 70px;
pointer-events: none
}
.container2:hover .overlay2 {
height: 85%;
}
.overlay3 {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: #4CAF50;
overflow: hidden;
width: 100%;
height: 0;
transition: .5s ease;
margin-left: 17%;
border-top-left-radius: 70px;
border-top-right-radius: 70px;
pointer-events: none
}
.container2:hover .overlay3 {
height: 85%;
}
.container{
宽度:400px;
高度:400px;
填充:0px;
显示:网格;
网格模板列:自动;
}
.项目{
宽度:100px;
高度:200px;
保证金:2倍;
}
.container{
宽度:400px;
高度:400px;
填充:0px;
显示:网格;
网格模板列:自动;
}
.项目{
宽度:100px;
高度:200px;
保证金:2倍;
}
对于这些场景,有一个漂亮/干净/简单的概念称为
flex
,它通过减少代码行数而有所帮助:
下面是具有列
、颜色
和悬停
效果的示例,希望它能帮助您:
#MainDiv{
高度:200px;
宽度:650px;
显示器:flex;
/*这里有一个概念*/
弯曲方向:行;
/*您可以将其更改为行/列*/
填充物:5px;
}
#第一组{
宽度:200px;
保证金:5px;
背景色:红色;
}
#二等兵{
宽度:200px;
保证金:5px;
背景颜色:蓝色;
}
#第三{
宽度:200px;
保证金:5px;
背景颜色:绿色;
}
#第一组:悬停{
背景颜色:蓝色;
颜色:白色;
}
#第二组:悬停{
背景颜色:绿色;
颜色:白色;
}
#第三,悬停{
背景色:红色;
颜色:白色;
}
第一组
第二组
第三组
对于这些场景,有一个漂亮/干净/简单的概念称为flex
,它通过减少代码行数而有所帮助:
下面是具有列
、颜色
和悬停
效果的示例,希望它能帮助您:
#MainDiv{
高度:200px;
宽度:650px;
显示器:flex;
/*这里有一个概念*/
弯曲方向:行;
/*您可以将其更改为行/列*/
填充物:5px;
}
#第一组{
宽度:200px;
保证金:5px;
背景色:红色;
}
#二等兵{
宽度:200px;
保证金:5px;
背景颜色:蓝色;
}
#第三{
宽度:200px;
保证金:5px;
背景颜色:绿色;
}
#第一组:悬停{
背景颜色:蓝色;
颜色:白色;
}
#第二组:悬停{
背景颜色:绿色;
颜色:白色;
}
#第三,悬停{
背景色:红色;
颜色:白色;
}
第一组
第二组
第三组
@Mahmoud Samy,这是你需要的吗?@Mahmoud Samy,这是你需要的吗?
.container2 {
float: left;
position: relative;
width: 250px;
}