gpt4 book ai didi

css - 水平菜单,位置固定,div 旁边

转载 作者:行者123 更新时间:2023-11-28 16:31:39 34 4
gpt4 key购买 nike

我有一个顶部水平菜单栏,宽度为 100%,居中对齐,位置固定,因此它不会随页面滚动。

但我还想在菜单左侧的菜单内联一个名称(例如名为 test)。

但即使我使用内联 block ,它也会根据左侧的 div 向下移动。

    <div class="name">test</div >

<div id="menu">
<ul>
<li><a href="index.php?menu=1" border="0" alt="menu1">menu1</a></li>
<li><a href="index.php?menu=1" border="0" alt="menu1">menu2</a></li>
<li><a href="index.php?menu=1" border="0" alt="menu1">menu3</a></li>
<li><a href="index.php?menu=1" border="0" alt="menu1">menu4</a></li>
<li><a href="index.php?menu=1" border="0" alt="menu1">menu5</a></li>

</ul>
</div>

和 CSS

.name {
font-size: 12pt;
font-weight: bold;
height: 20px;
color: #ffffff ;
Width: 99%;
display: ;
position:fixed;
z-index:2;
padding: 5px;
top: 2px;
}


#menu {
background: #bbbbbb;
top: 0px;
height: 35px;
width: 99.8% ;
text-align: center ;
position:fixed;
z-index:1;
}


}

#menu ul{
display: ;
height: auto;
padding: 8px 0px;
margin: 0px;
z-index:3;
}

#menu li {
display: inline;
z-index:3;
}



#menu a {
display: inline-block;
font-weight: bold;
font-size: 15px;
color: red;
text-decoration: none;
vertical-align: bottom;
padding: 20px;

}

参见示例:https://jsfiddle.net/sm6npxdc/3/

最佳答案

试试这个:

.name {
font-size: 12pt;
font-weight: bold;
height: 20px;
color: #ffffff;
Width: 99%;
display: inline-block;
position: fixed;
z-index: 2;
padding: 5px;
top: 2px;
}
#menu {
background: #bbbbbb;
top: 0px;
height: 35px;
width: 99.8%;
text-align: center;
position: fixed;
z-index: 1;
}
#menu ul {
line-height: 2.000;
padding: 0px;
margin: 0px;
z-index: 3;
margin: 0px;
}
#menu ul li {
display: inline-block;
z-index: 3;
padding: 0px 12px;
}
#menu a {
font-weight: bold;
font-size: 15px;
color: red;
text-decoration: none;
}
<div class="name">test</div>

<div id="menu">
<ul>
<li><a href="index.php?menu=1" border="0" alt="menu1">menu1</a>
</li>
<li><a href="index.php?menu=1" border="0" alt="menu1">menu2</a>
</li>
<li><a href="index.php?menu=1" border="0" alt="menu1">menu3</a>
</li>
<li><a href="index.php?menu=1" border="0" alt="menu1">menu4</a>
</li>
<li><a href="index.php?menu=1" border="0" alt="menu1">menu5</a>
</li>

</ul>
</div>

<div style='clear:both; margin-top:40px;'>
</div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta.
Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero. Sed dignissim lacinia nunc. Curabitur tortor. Pellentesque nibh. Aenean quam.
In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla
metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam nec ante. Sed lacinia, urna non tincidunt mattis, tortor
neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Quo usque tandem abutere, Catilina, patientia nostra? Quam diu etiam
furor iste tuus nos eludet? Quem ad finem sese effrenata iactabit audacia? CICERO Etiam ultrices. Suspendisse in justo eu magna luctus suscipit. Sed lectus. Integer euismod lacus luctus magna. Quisque cursus, metus vitae pharetra auctor, sem massa mattis
sem, at interdum magna augue eget diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi lacinia molestie dui. Praesent blandit dolor. Sed non quam. In vel mi sit amet augue congue elementum. Morbi in ipsum
sit amet pede facilisis laoreet. Donec lacus nunc, viverra nec, blandit vel, egestas et, augue. Vestibulum tincidunt malesuada tellus. Ut ultrices ultrices enim. Curabitur sit amet mauris. Morbi in dui quis est pulvinar ullamcorper. Nulla facilisi. Integer
lacinia sollicitudin massa. Cras metus. Sed aliquet risus a tortor. Integer id quam. Morbi mi. Quisque nisl felis, venenatis tristique, dignissim in, ultrices sit amet, augue. Proin sodales libero eget ante. Nulla quam. Aenean laoreet. Vestibulum nisi
lectus, commodo ac, facilisis ac, ultricies eu, pede.

或在 Jsfiddle 中查看此演示

关于css - 水平菜单,位置固定,div 旁边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35235650/

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