gpt4 book ai didi

css - 如何格式化
中的文本以使用动画平滑滚动?

转载 作者:行者123 更新时间:2023-11-28 01:09:57 25 4
gpt4 key购买 nike

我有这个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 Logo 的动画。由于某些奇怪的原因,我目前无法放置任何文本。任何帮助将不胜感激。

最佳答案

我认为您的一种选择是使用 display:nonevisibility:hidden 在您不想显示文本时隐藏文本,而不是弄乱 z-indexes 和过渡。从您的代码中不是很清楚您是否希望文本在可见时溢出框。我将其放置在框中。我调整了文字大小,但如果你想让它们更小/更大,你可以调整。我添加了颜色(只是为了让我可以看到它们从哪里开始)。再次,可调整。

这是 fiddle和片段:

@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>

关于css - 如何格式化 <div> 中的文本以使用动画平滑滚动?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52155183/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com