简体   繁体   English

下拉菜单框的大小不同

[英]drop down menu box sizes are different

I am fairly new to the whole Web making world. 我对整个Web制作世界还很陌生。
I am having trouble with my drop down menu. 我的下拉菜单有问题。 The boxes in the drop down menu are different sizes depending on the word in it. 下拉菜单中的框大小取决于其中的单词。

Is there anyway I can make these boxes all the same size as the biggest on and align the words left as well? 无论如何,我可以使这些盒子的尺寸与最大盒子的尺寸相同,并同时对齐左边的单词吗?

HTML 的HTML

 <div id="navigation" class="radius">  


<ul>
            <li><a href="index.html"><strong>Home</strong> </a></li>
            <li><a href="Graphics Work.html">Graphics and Photography</a>
            <ul>
                    <li><a href="#">Landscapes</a></li> 
                    <li><a href="#">Special FX</a></li> 
                    <li><a href="#">Advert Shots</a></li>

            </ul>  
            </li>                   
            <li><a href="Film Work.html">Film Work</a></li>
            <li><a href="#Contactus">Contact Me </a></li>
            <li><a href="#About Me">About Me </a></li>

         </ul>
        </div>

CSS 的CSS

    #navigation {Width:100%; height:60px; background-color:#333;} 

#navigation ul{font-family: "Capitals", "Times", "Lucida Grande", "Lucida     Sans Unicode", "Lucida Sans", "DejaVu Sans", "Verdana", "sans-serif"; display:     inline-block;  
padding:10px; margin-left:5px; margin-top:5px; list-style-type:none; }

#navigation ul li {float:left; display:block;}

#navigation ul li ul {display:none;}

#navigation ul li ul li {display:block; float:none; padding-bottom:6px;     margin-left:55px;}

#navigation ul li ul li a {text-align:left; z-index:99; margin:auto;}

#navigation ul ul {visibility:hidden; }

#navigation ul li a{background:#333; color: #fff; padding:8px 69px;     position:relative; text-decoration:none; }

#navigation ul li:hover ul {display:block; visibility:visible; margin-    top:20px;  }

#navigation ul li a:hover{text-decoration:underline; color:#1B76AE;}

You css had some issues. 您的CSS有一些问题。 I've fixed your CSS and applied some new CSS. 我已经修复了CSS并应用了一些新的CSS。 Here is working snippet 这是工作片段

 *{ box-sizing: border-box; } #navigation { Width: 100%; background-color: #333; } #navigation > ul { font-family: "Capitals", "Times", "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", "Verdana", "sans-serif"; display: block; padding: 10px; margin-left: 5px; margin-top: 5px; list-style-type: none; } #navigation > ul:after{ clear:both; content:""; display: block; } #navigation > ul > li { position:relative; float: left; } #navigation ul > li > a { display:block; background: #333; color: #fff; padding: 8px 30px; position: relative; text-decoration: none; } #navigation > ul > li > ul { display: none; position:absolute; left:0; width:100%; list-style: none; padding: 0; } #navigation > ul > li > ul > li { display: block; float: none; position:relative; width:100%; } #navigation > ul > li > ul > li > a { text-align: left; z-index: 99; margin: auto; display:block; } #navigation > ul > li:hover > ul { display: block; } #navigation > ul > li > a:hover { text-decoration: underline; color: #1B76AE; } 
 <div id="navigation" class="radius"> <ul> <li><a href="index.html"><strong>Home</strong> </a></li> <li><a href="Graphics Work.html">Graphics and Photography</a> <ul> <li><a href="#">Landscapes</a></li> <li><a href="#">Special FX</a></li> <li><a href="#">Advert Shots</a></li> </ul> </li> <li><a href="Film Work.html">Film Work</a></li> <li><a href="#Contactus">Contact Me </a></li> <li><a href="#About Me">About Me </a></li> </ul> </div> 

Use the width property in CSS for it. 在CSS中使用width属性。 For the purpose of this example, I used inline style. 出于本示例的目的,我使用了内联样式。 You should preferably go with a separate stylesheet. 您最好使用单独的样式表。

<select style="width: 10%;" >
<option>Some content</option>
<option>Some more content </option>
<option>Some more content </option>
<option>Some more content </option>
<option>Some more content </option>
<option>Some more content </option>
</select>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM