[英]css display inline not working
So i ve been working on this for several hours.. i have a problem in the nav bar where the content refuses to go display: inline. 因此,我已经为此工作了几个小时。.我在导航栏中遇到了一个问题,其中内容拒绝显示:内联。 Previous versions worked fine but were too disorganized , code wise. 以前的版本运行良好,但在代码方面过于混乱。 here is my code. 这是我的代码。
CSS: CSS:
body {
background-color: #5C7584;
margin: 0 auto;
//width: 1000px;
width: 100%;
margin-top: 10px;
}
#canvas {
width: 1000px;
margin: 0 auto;
background-color: white;
}
a {
color: #4086b6;
text-decoration: none;
}
///////////////////////////////////
ul, li {
list-style: none;
}
ul li {
//padding-right: 10px;
//padding-left: 10px;
//display: inline;
}
.parentClass {
display: inline;
//position: relative;
list-style: none;
//float: left;
}
.dropDown {
position: relative;
background-color: lightcyan;
display: block;
list-style: inherit;
//text-align: right;
//background-color: lightcyan;
width: auto;
height: 0px;
visibility: hidden;
opacity: 0;
-webkit-transition: all .25s;
-moz-transition: all .25s;
-ms-transition: all .25s;
-o-transition: all .25s;
transition: all .5s;
}
#linkline{
}
.parentClass:hover {
background-color: lightcyan;
}
.parentClass:hover .dropdown {
opacity: 1;
visibility: visible;
height: auto;
}
/////////////////////////////
#toplinks a {
//padding-left: 0px;
text-shadow: 1px 1px lightgrey;
}
#toplinks a:hover {
color: lightskyblue;
//border-radius: 50px 50px;
}
#toplinks a:active {
color: white;
}
#top {
height: 102px;
background-image: url("../assets/topbar_plain.png");
background-color: white;
opacity: .9;
z-index: 2;
position: relative;
}
#toplinks {
float: right;
width: 500px;
text-align: right;
padding-right: 30px;
padding-top: 70px;
}
#logo {
background-image: url("../assets/logo_plain.png");
width: 102px;
height: 33px;
float: left;
background-repeat: no-repeat;
margin-top: 40px;
margin-left: 80px;
}
HTML: HTML:
<div id="top" >
<div id="canvas">
<a href="index.php" id="logo"> </a>
<div id="toplinks">
<ul class="linkline">
<li id="indexx" class="parentClass"><a href="./index.php">Overview</a>
<ul></ul>
</li>
<li class="parentClass"><a href="#">Services</a>
<ul class="dropDown">
<li class="c2"> <a href="./ddos_mitigation.php">DDoS Mitigation</a> </li>
<li class="c1"> <a href="./serverhosting.php">Server Hosting</a> </li>
</ul>
</li>
<li class="parentClass"><a href="#">AboutUs</a>
<ul class="dropDown">
<li class="c2"> <a href="#">Link 1</a> </li>
<li class="c1"> <a href="#">Link 2</a> </li>
<li class="c2"> <a href="#">Link 3</a> </li>
</ul>
</li>
</ul>
</div>
</div>
</div>
尝试:
display:inline-block
ul { list-style: none; } li { float: left; display: block; margin: 0 1em 0 0; border: 1px solid purple; }
<ul> <li>Menu item 1</li> <li>Menu item 2</li> </ul>
Hi, I simplified your code down to the lists and their styling which is what you need to fix. 嗨,我将您的代码简化为列表及其样式,这是您需要解决的问题。 Make sure ul is list-style none and the li's in that list are float left display block and then style from there. 确保ul是列表样式的,并且列表中的li浮动在显示块的左侧,然后从此处进行样式设置。
Try to change the parentClass like that. 尝试像这样更改parentClass 。
.parentClass {
display: inline-block;
position: relative;
list-style: none;
float: left;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.