我有这个JSfiddle。这是我网站上正在进行的部分。我在代码片段中遇到的问题是,当调整CSS的高度、宽度百分比值时,文本的大小将不正确,最重要的是,调整顶部和左侧的位置。我不知道我的定位是否不正确。我不是最擅长知道什么时候在什么特定情况下使用什么职位的人。
代码:
@charset "utf-8";
/* CSS Document */
.Experience_Target {
display: inline-block;
}
.EXP1Box {
height: 100vh;
overflow: hidden;
}
#Hangar {
top: 0;
height: 50%;
}
#Virtual {
top: 0;
height: 50%;
}
.Hangar {
background: url(https://s8.postimg.cc/d56er2eut/Hangar_Phot.png);
height: 50%;
width: 100%;
background-position: 75%;
background-repeat: no-repeat;
transition: all .5s ease;
-moz-transition: all .5s ease;
-ms-transition: all .5s ease;
-webkit-transition: all .5s ease;
-o-transition: all .5s ease;
webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.Hangar:hover {
box-shadow: inset 0 0 0 150vw rgba(0, 0, 0, 0.7);
-moz-transform: scale(1.1);
-webkit-transform: scale(1.1);
-o-transform: scale(1.1);
-ms-transform: scale(1.1);
/* IE 9 */
transform: scale(1.1);
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=1.5, M12=0, M21=0, M22=1.5, SizingMethod='auto expand')";
filter: progid:DXImageTransform.Microsoft.Matrix(M11=1.5, M12=0, M21=0, M22=1.5, SizingMethod='auto expand');
}
.NextEra {
position: relative;
width: 0%;
height: 0%;
top: 3.5%;
left: 40%;
z-index: 1;
transition: .5s ease;
-moz-transition: .5s ease;
-ms-transition: .5s ease;
-webkit-transition: .5s ease;
-o-transition: .5s ease;
}
.Hangar:hover .NextEra {
position: relative;
width: 70%;
height: auto;
top: 0.0%;
left: 26.3%;
z-index: 1;
}
h3 {
font-family: "Myriad Pro";
font-size: 63px;
color: white;
}
h4 {
font-family: "Myriad Pro";
font-size: 64px;
color: white;
}
.Hangar:hover .NextText1 {
position: relative;
top: 60%;
left: -18%;
z-index: 2;
font-style: italic;
}
.NextText1 {
position: relative;
top: -300%;
left: 0%;
z-index: 2;
}
.Hangar:hover .NextText2 {
position: relative;
top: -300%;
left: 2%;
z-index: 2;
width: 30%
}
.NextText2 {
position: relative;
top: 100%;
left: 18%;
z-index: 2;
}
<section class="EXP1Box">
<div class="Hangar">
<div class="NextEra">
<div class="NextEra">
<img alt="NextEra" src="https://s8.postimg.cc/h1jqn4zv9/Next_Era_Pop.png" class="NextEra">
</div>
<div class="NextText1">
<h4 class="NextText1">Future Ambitions</h4>
</div>
<div class="NextText2">
<h3 class="NextText2">Internship Position With:</h3>
</div>
</div>
</div>
<div class="Virtual">
</div>
</section>
我想做的是,当有人没有悬停在图片上时,文本要小而不在页面上,但当有人悬停在图片上方时,文本会变大并占据图像的一半——类似于左侧NextEra标志的动画。由于某种奇怪的原因,我现在无法定位任何文本。如有任何帮助,我们将不胜感激。
我认为一种选择是在不想显示文本时使用display:none
或visibility:hidden
来隐藏文本,而不是干扰z索引和转换。从您的代码中不太清楚您是否希望文本在可见时溢出框。。我把它放在盒子里。我调整了文本大小,但如果你想让它们变小/变大,你可以调整。我添加了颜色(只是为了让我能看到它们从哪里开始)。。再次,可调整。
这是小提琴和片段:
@charset "utf-8";
/* CSS Document */
.Experience_Target {
display: inline-block;
}
.EXP1Box {
height: 100vh;
overflow: hidden;
}
#Hangar {
top: 0;
height: 50%;
}
#Virtual {
top: 0;
height: 50%;
}
.Hangar {
background: url(https://s8.postimg.cc/d56er2eut/Hangar_Phot.png);
height: 50%;
width: 100%;
background-position: 75%;
background-repeat: no-repeat;
transition: all .5s ease;
-moz-transition: all .5s ease;
-ms-transition: all .5s ease;
-webkit-transition: all .5s ease;
-o-transition: all .5s ease;
webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
/*background-attachment: fixed;
Really wish I could make this work.
Fucks up because of zoom*/
}
.Hangar:hover {
box-shadow: inset 0 0 0 150vw rgba(0, 0, 0, 0.7);
-moz-transform: scale(1.1);
-webkit-transform: scale(1.1);
-o-transform: scale(1.1);
-ms-transform: scale(1.1);
/* IE 9 */
transform: scale(1.1);
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=1.5, M12=0, M21=0, M22=1.5, SizingMethod='auto expand')";
filter: progid:DXImageTransform.Microsoft.Matrix(M11=1.5, M12=0, M21=0, M22=1.5, SizingMethod='auto expand');
}
.NextEra {
position: relative;
width: 0%;
height: 0%;
top: 3.5%;
left: 40%;
z-index: 1;
transition: .5s ease;
-moz-transition: .5s ease;
-ms-transition: .5s ease;
-webkit-transition: .5s ease;
-o-transition: .5s ease;
}
.Hangar:hover .NextEra {
position: relative;
width: 70%;
height: auto;
top: 0.0%;
left: 26.3%;
z-index: 1;
}
h3 {
font-family: "Myriad Pro";
font-size: 63px;
color: blue;
}
h4 {
font-family: "Myriad Pro";
font-size: 64px;
color: green;
}
.NextText1 {
color: forestgreen;
margin-left: 30px;
margin-top: 10px;
position: relative;
z-index: 2;
font-style: italic;
visibility: visible;
}
.Hangar:hover .NextText1 {
/*margin-left: 18%;
z-index: 2;*/
visibility: hidden;
}
.Hangar:hover .NextText2 {
position: fixed;
visibility: visible;
top: 10%;
left: 2%;
z-index: 2;
width: 30%;
margin-left: 18%;
font-size: 30px;
color: red;
}
.NextText2 {
visibility: hidden;
}
<section class="EXP1Box">
<div class="Hangar">
<div class="NextEra">
<div class="NextEra">
<img alt="NextEra" src="https://s8.postimg.cc/h1jqn4zv9/Next_Era_Pop.png" class="NextEra">
</div>
<div class="NextText1">
<h4 class="NextText1">Future Ambitions</h4>
</div>
<div class="NextText2">
<h3 class="NextText2">Internship Position With:</h3>
</div>
</div>
</div>
<div class="Virtual">
</div>
</section>