【发布时间】:2020-07-10 17:34:31
【问题描述】:
过去几天我一直在学习 html/css,并制作了一些初学者页面。 我试图在大图片上放置一个基本的悬停覆盖。悬停覆盖在图像上有一些基本文本和低不透明度灰色填充。我的问题是我认为文本出现在覆盖层后面。所以文字似乎稍微改变了颜色,但从黑色变为白色并不清楚等。 我希望这更具体一些,并符合指导方针。 感谢任何帮助我的人!
html代码
<!DOCTYPE html>
<html>
<head>
<title>SHAYMAC</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<header id="main-header">
<div class="container">
<h1>SHAYMAC</h1>
</div>
</header>
<nav id="nav-bar">
<div class="container">
<ul>
<li><a href="https://www.google.com/">home</a> </li>
<li><a href="#">about</a> </li>
<li><a href="#">service</a> </li>
</ul>
</div>
</nav>
<div class="pic">
<div class="text"><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod</p></div>
</div>
<footer>
</footer>
</body>
</html>
css代码
body{
background-color:#333;
color:#fff;
font-family:Arial, Helvetica, sans-serif;
font-size:16px;
line-height: 1.6em;
margin:0;
}
.container{
width:80%;
margin:auto;
overflow:hidden;
}
.pic{
background-image: url(../images/desk.jpg);
background-position: center ;
min-height: 300px;
margin-bottom:30px;
text-align: center ;
}
.pic:hover{
opacity:0.3;
filter: alpha(opacity=30);
transition: .5s ease;
}
.text{
padding-top:135px;
color:#000;
opacity:0;
position: relative;
text-align: center;
}
.pic:hover .text{
color:#fff;
opacity:0.6;
text-align: center;
font-size:20px;
font-weight:700;
font-family:"Arial", Times, serif;
padding-top:135px;
transition: .5s ease;
position:relative;
}
#main-header{
background-color:#000;
color:#fff;
padding:10;
}
#nav-bar{
background-color:#000;
color:#fff;
}
#nav-bar ul{
padding:10;
list-style: none;
}
#nav-bar li{
display: inline;
}
#nav-bar a{
color:#fff;
text-decoration: none;
font-size:18px;
padding-right:15px;
}
#nav-bar a: hover{
color: #coral;
}
#showcase{
background-image: url(../images/showcase.jpg);
background-position: center right;
min-height: 300px;
margin-bottom:30px;
text-align: center ;
}
#showcase h1{
color: #fff;
font-size: 50px;
line-height: 1.6em;
padding-top: 30px;
}
【问题讨论】:
-
欢迎来到 Stack Overflow!请访问help center、tour 以查看内容和How to Ask。做一些研究,搜索关于 SO 的相关主题;如果您遇到困难,请发布您的尝试minimal reproducible example,并注明输入和预期输出。显示代码,而不是代码图片!!!而是单击编辑,然后单击
[<>]stacksn-p 并给我们一个工作示例 -
请分享您目前拥有的代码,以便我们能够提供帮助。否则,您可能无法获得帮助,因为您的问题太广泛了
-
请将代码共享为文本而不是打印屏幕。没有人有时间重写您的代码并猜测缺少的部分以帮助您
标签: html css text colors hover