我有一个带有两个背景图像的分屏。我在每一边都有一个image.png和一个image-hover.png。当我将光标放在背景图像或image.png上时,我想将image-hover.png放在image.png的顶部。
我设法做到这一点,但是当我把光标放在背景图像上时,悬停在image.png上激活,当我将光标拖到image.png上时,悬停消失了。
这是我的页面:http://loopaa.com/split/
这是我的代码:
@import url('https://fonts.googleapis.com/css?family=Open+Sans:400,600,800');
html, body {
height: 100%;
min-height: 18em;
background: linear-gradient(90deg, #534591 50%, #e2d649 50%);
}
.stanga {
background-image: url("http://loopaa.com/split/left-side.png");
height: 100%;
}
.dreapta {
background-image: url("http://loopaa.com/split/right-side.png");
height: 100%;
}
.split-pane {
padding-top: 22%;
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
height: 100%;
font-size: 2em;
color: white;
font-family: 'Open Sans', sans-serif;
font-weight:300;
}
.split-pane > div {
position: relative;
top: 40%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
text-align: center;
}
.split-pane > div .text-content {
line-height: 1.6em;
margin-bottom: 1em;
}
.split-pane > div .text-content .big {
font-size: 2em;
text-decoration:none;
}
#cf{margin: auto;
width: 400px;}
#cf .left-cheery{
width: 400px;
height: 360px;
background: url(http://loopaa.com/split/cc.png);
border:0;
transition: all 0.35s ease-in-out;
}
.stanga:hover .left-cheery{
background: url(http://loopaa.com/split/cc-hover.png) !important;
transition: all 1s ease-in;
}
#cf .right-cheery{
width: 400px;
height: 360px;
background: url(http://loopaa.com/split/cc2.png);
border:0;
transition: all 0.35s ease-in-out;
}
.dreapta:hover .right-cheery{
background: url(http://loopaa.com/split/cc2-hover.png) !important;
transition: all 1s ease-in;
}
.split-pane button, .split-pane a.button-left, .split-pane a.button-right {
font-family: 'Open Sans', sans-serif;
font-weight:800;
background: none;
border: 1px solid #3b3277;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
width: 15em;
padding: 0.7em;
font-size: 0.5em;
text-decoration: none;
color: #3b3277;
display: inline-block;
cursor: pointer;
-moz-transition: all 0.2s ease-out;
-o-transition: all 0.2s ease-out;
-webkit-transition: all 0.2s ease-out;
transition: all 0.2s ease-out;
}
.split-pane button:hover, .split-pane a.button-left:hover {
text-decoration: none;
background-color: #3b3277;
border-color: #3b3277;
cursor: pointer;
}
.button-left{border: 1px solid #e1d622 !important;color:#e1d622 !important;margin-bottom:6px;}
.button-left:hover{background-color:#e1d622 !important;color:#3b3277 !important;}
.button-right{border: 1px solid #3b3277 !important;color:#3b3277 !important;margin-bottom:6px;}
.button-right:hover{background-color:#3b3277 !important;color:#e1d622 !important;}
.uiux-side.split-pane button:hover, .split-pane a.button-left:hover {
color: #ffffff;
}
.frontend-side.split-pane button:hover, .split-pane a.button-left:hover {
color: blue;
}
#bg-logo{ border-radius: 50%;
width: 125px;
height: 125px;
background:#ffffff;
margin: auto;
padding-top:38px;
}
#split-pane-or {
font-size: 2em;
color: white;
font-family: 'Open Sans', sans-serif;
text-align: center;
width: 100%;
position: absolute;
top: 43.5%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.big {
font-size: 2em;
}
#slogan {
position: absolute;
width: 100%;
z-index: 100;
text-align: center;
vertical-align: baseline;
top: 0.5em;
color: white;
font-family: 'Open Sans', sans-serif;
font-size: 1.4em;
}
#slogan img {
height: 0.7em;
}
.text-content p{
text-transform:uppercase;
font-size:1.6rem;
font-weight:600;
line-height: 140%;
margin-top:12px;
}
.big {
font-weight:800;
}
@media only screen and (max-width: 1368px) {
.split-pane {}
.split-pane > div .text-content .big {font-size: 1em;}
.split-pane > div .text-content {line-height: 1em;margin-bottom: 0;}
.text-content p{margin-top: 8px;font-size: 1.4rem;}
}
@media only screen and (max-width: 1025px) {
.split-pane{}
.split-pane > div .text-content .big {font-size: 1.4em;}
#cf .left-cheery{
width: 200px;
height: 180px;
background: url(http://loopaa.com/split/cc-min.png);
}
.stanga:hover .left-cheery{
background: url(http://loopaa.com/split/cc-min-hover.png) !important;
}
#cf {width:200px;}
#cf .right-cheery{
width: 200px;
height: 180px;
background: url(http://loopaa.com/split/cc-min.png);
}
.dreapta:hover .right-cheery{
background: url(http://loopaa.com/split/cc-min-hover.png) !important;
}
}
@media (max-width:801px) and (min-width:738px) {
#bg-logo{display:none;}
.split-pane {}
.split-pane > div .text-content {line-height: 1.6em;margin-bottom: 10px;}
}
@media only screen and (max-width: 737px) {
#bg-logo{display:none;}
.split-pane {padding-top: 5%;}
.split-pane > div .text-content .big {font-size: 1em;}
.split-pane > div .text-content {line-height: 1em;margin-bottom: 0;}
.text-content p{margin-top: 8px;font-size: 1.4rem;}
}
@media only screen and (max-width:569px){
#cf{display:none;}
.split-pane > div .text-content .big {font-size: 1em;}
.split-pane > div .text-content {line-height: 1em;margin-bottom: 0;}
.text-content p{margin-top: 8px;font-size: 1.4rem;}
}
@media only screen and (max-width:568px){
#cf{display:none;}
.split-pane > div .text-content .big {font-size: 0.9em;}
.split-pane > div .text-content {line-height: 1em;margin-bottom: 0;}
.text-content p{margin-top: 8px;font-size: 1rem;}
}
<head>
<meta charset="UTF-8">
<title>Cheerup</title>
<link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css'>
</head>
<body>
<div class='split-pane col-xs-12 col-sm-6 stanga' id="body-half-color">
<div>
<div id="cf">
<div class="left-cheery"></div>
</div>
<div class='text-content' style="color:#e1d622;">
<!--<div class="bold">Photobooth for</div>-->
<div class='big'>CORPORATE CHEERY</div>
<p>Oferim experiențe memorabile, pline de zâmbete și veselie,<br /> la orice tip de eveniment business</p>
</div>
<a class='button-left'>
AFLA CUM
</a>
</div>
</div>
<div class='split-pane col-xs-12 col-sm-6 dreapta'>
<div>
<div id="cf">
<div class="right-cheery"></div>
</div>
<div class='text-content' style="color:#3b3277;">
<div class='big'>PRIVATE PARTY CHEERY</div>
<p>Cu noi, distracția primează în rândul celor alături de care ai ales să<br /> petreci una din cele mai importante zile din viața ta</p>
</div>
<a class='button-right'>
AFLA CUM
</a>
</div>
</div>
<div id='split-pane-or'>
<div id="bg-logo">
<img src='http://loopaa.com/split/logo-cheerup-mic.png' />
</div>
</div>
</body>
我希望我正确地描述并且你理解了这个问题。
答案 0 :(得分:0)
我通常采取的解决CSS问题的方法是在所有内容周围添加彩色边框 - 我已经在您的代码中执行了此操作:
http://jsfiddle.net/kNB3c/429/
然后你可以看到你的悬停失败的部分(因为你已经为边框着色)所以它在上面的蓝色部分失败了..这是#split-pane-or
这是您的中间徽标的部分,这将需要它的宽度减少到大约20%(或者你想要那个部分的小)
你可以在#split-pane内部使用宽度属性,或者像这样:
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
width: 20%;
或者让宽度更小,这样你就可以在该部分上空盘旋..
P.S。很好的设计!