html - 固定菜单在图像悬停效果上消失

我对HTML 和CSS 中的编码相当陌生。

我有以下 HTML 和 CSS 代码,一个固定的菜单导航栏和一个对悬停产生影响的图像。

放大时如何使图像不阻挡菜单?

另外,我如何不拉伸图像,而是调整发布它的 div 的大小以稍微调整浏览器屏幕?

* {background-color: black
}
*{
    padding: 0;
    margin: 0;
}

ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: visible;
  background-color: black;
  font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
  font-size: 20px;
  font-weight: bold;
  height: 65px;
  border-style: dashed;
  border-color:green;
  border-radius: 20px;
  height: 80px;
}

li {
  float: left;
}

li a {
  display: block;
  color: white;
  text-align: center;
  padding: 10px 12px;
  text-decoration: none;
  border-style: dotted;
  margin-left: 24px;
  margin-top: 11px;
}

li a:hover {
  background-color: red;
}

.parrafo{
    font-size: 40px;
    padding: 75px;
    border-radius: 10px;
    margin-top: 10px;
    margin-bottom: 10px;
    border-left: 22px;
    padding-left: 150px;
    border-top: dotted 5px red;
    border-bottom: dotted 5px yellowgreen;
    display: flex;
    flex-direction: row;
    font-family: sans-serif;
    font-weight: bold;
    color: white;
    
}

.queonda{
font-family: sans-serif;
font-weight: bold;
color: white;
font-size: 50px;
margin-left: 85px;
}

.test{
    margin-left: 200px;
    margin-top: 270px;
}

.test2{
    margin-top: 100px;
    margin-bottom: 100px;
    margin-left: 700px;
}

.portrait {
  overflow: hidden;
  display: inline-block;
}

.portrait img {
  transition: transform 0.5s linear;
  max-width: 100%;
  max-height: 100%;
}

.portrait:hover img {
  transform: scale(1.1);
}

.cat {
 height: 1250px;
 width: 1900px;
}

.algo {
    height: 880px;
    width: 1700px;
    display: block;
}

.active {
  overflow: hidden;
  background-color: #333;
  position: fixed;
  top: 0;
  width: 100%;
}
<div class="active">
    <ul>
        <li><a href="#home">Tour</a></li>
        <li><a href="#news">Listen to Music</a></li>
        <li><a href="#contact">Contact</a></li>
        <li><a href="#about">About</a></li>
    </ul>
</div>

<div class="portrait algo"><img src="https://i.ibb.co/dLrSmP7/1111.jpg" alt=""></div>

<div class="parrafo">
    <img src="https://muzikercdn.com/uploads/products/4207/420772/09821a89.jpg" alt="Ciudad con Transito">
    <P class="test">MUSIC<br>MAINSTREAM   SELLOUT</P>
</div>

<div class="test2">
    <P class="queonda">VIDEOS</P><br><br>
    <video width="1280" controls autoplay="off">
        <source src="./img/prueba2.mp4" type="video/mp4">

</div>

<footer class="footer">
    <div class="container">
        <div class="row">
            <div class="footer-col">
                <h4>Terms & Conditions</h4>
            </div>
            <div class="footer-col">
                <h4><a class="textDecoration" href="#privacy">Privacy and Policy</a></h4>
            </div>

            <div class="footer-col">
                <h4>Follow Us</h4>
                <div class="social-links">

                </div>
            </div>
            <div class="footer-col">
                <div class="social-links">
                    <h3><a href="#" class="fa fa-facebook"></a>
                        <a href="#" class="fa fa-twitter"></a>
                        <a href="#" class="fa fa-instagram"></a>
                        <a href="#" class="fa fa-youtube"></a>
                    </h3>
                </div>
            </div>
        </div>
</footer>

希望你们能给我一些指导来解决这个问题:)

回答1

只需在导航中添加任何积极的 https://developer.mozilla.org/en-US/docs/Web/CSS/z-index 即可。

* {background-color: black
}
*{
    padding: 0;
    margin: 0;
}

.navigation {
  z-index: 1;
}

ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: visible;
  background-color: black;
  font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
  font-size: 20px;
  font-weight: bold;
  height: 65px;
  border-style: dashed;
  border-color:green;
  border-radius: 20px;
  height: 80px;
}

li {
  float: left;
}

li a {
  display: block;
  color: white;
  text-align: center;
  padding: 10px 12px;
  text-decoration: none;
  border-style: dotted;
  margin-left: 24px;
  margin-top: 11px;
}

li a:hover {
  background-color: red;
}

.parrafo{
    font-size: 40px;
    padding: 75px;
    border-radius: 10px;
    margin-top: 10px;
    margin-bottom: 10px;
    border-left: 22px;
    padding-left: 150px;
    border-top: dotted 5px red;
    border-bottom: dotted 5px yellowgreen;
    display: flex;
    flex-direction: row;
    font-family: sans-serif;
    font-weight: bold;
    color: white;
    
}

.queonda{
font-family: sans-serif;
font-weight: bold;
color: white;
font-size: 50px;
margin-left: 85px;
}

.test{
    margin-left: 200px;
    margin-top: 270px;
}

.test2{
    margin-top: 100px;
    margin-bottom: 100px;
    margin-left: 700px;
}

.portrait {
  overflow: hidden;
  display: inline-block;
}

.portrait img {
  transition: transform 0.5s linear;
  max-width: 100%;
  max-height: 100%;
}

.portrait:hover img {
  transform: scale(1.1);
}

.cat {
 height: 1250px;
 width: 1900px;
}

.algo {
    height: 880px;
    width: 1700px;
    display: block;
}

.active {
  overflow: hidden;
  background-color: #333;
  position: fixed;
  top: 0;
  width: 100%;
}
<div class="navigation active">
    <ul>
        <li><a href="#home">Tour</a></li>
        <li><a href="#news">Listen to Music</a></li>
        <li><a href="#contact">Contact</a></li>
        <li><a href="#about">About</a></li>
    </ul>
</div>

<div class="portrait algo"><img src="https://i.ibb.co/dLrSmP7/1111.jpg" alt=""></div>

<div class="parrafo">
    <img src="https://muzikercdn.com/uploads/products/4207/420772/09821a89.jpg" alt="Ciudad con Transito">
    <P class="test">MUSIC<br>MAINSTREAM   SELLOUT</P>
</div>

<div class="test2">
    <P class="queonda">VIDEOS</P><br><br>
    <video width="1280" controls autoplay="off">
        <source src="./img/prueba2.mp4" type="video/mp4">

</div>

<footer class="footer">
    <div class="container">
        <div class="row">
            <div class="footer-col">
                <h4>Terms & Conditions</h4>
            </div>
            <div class="footer-col">
                <h4><a class="textDecoration" href="#privacy">Privacy and Policy</a></h4>
            </div>

            <div class="footer-col">
                <h4>Follow Us</h4>
                <div class="social-links">

                </div>
            </div>
            <div class="footer-col">
                <div class="social-links">
                    <h3><a href="#" class="fa fa-facebook"></a>
                        <a href="#" class="fa fa-twitter"></a>
                        <a href="#" class="fa fa-instagram"></a>
                        <a href="#" class="fa fa-youtube"></a>
                    </h3>
                </div>
            </div>
        </div>
</footer>

相似文章

最新文章