简体   繁体   English

如何在导航栏中对齐文本的位置?

[英]How do I align the position of the text in the nav bar?

What is being shown now. 现在正在显示什么。

I want the text in the nav bar to be more aligned towards the center of the white bar and the menu icon to be aligned with the word "Menu" . 我希望导航栏中的文本更加朝向白色条的中心,并且菜单图标与单词“ Menu”对齐。

Any guidance is appreciated. 任何指导表示赞赏。

HTML code : HTML代码:

<!doctype html>

<html>
    <head>
        <meta charset="UTF-8"/>
        <title> Foodstant Delivery </title>
        <link rel="stylesheet" type="text/css" media="screen" href="stylo.css" />
        <link rel="shortcut icon" href="images/favicon.ico" />
    </head>

<body>
    <div id="container">
        <figure id="logo"> 
            <img src="images/logo22.png" alt="Foodstant Delivery logo" width="" height="" />
        </figure>   

        <figure id="abtex">
            <img src="images/abtex222.png" />
        </figure>   

<div id="navbar">
    <ul>
        <li class="OP"><img src="images/order.png" /><a  href="Orders.html">Orders</a></li>
        <li class="MP"><img src="images/menupic3.png" /><a  href="Menu.html">Menu</a></li>
        <li class="CUP"><img src="images/contact.png" /><a href="ContactUs.html">Contact</a></li>
        <li class="TCP"><img src="images/Pen.png" /><a href="Jobs.html" target="_blank">About</a></li>
        <li class="JP"><img src="images/pin.png" /><a  href="TC.html">Jobs</a></li>
    </ul>   
</div>

</div>

</body> 

</html> 

CSS code: (relevant) CSS代码:(相关)

#navbar {
    background: rgb(246,248,249); /* Old browsers */
    background: -moz-linear-gradient(top,  rgba(246,248,249,1) 0%, rgba(229,235,238,1) 46%, rgba(215,222,227,1) 65%, rgba(245,247,249,1) 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(246,248,249,1)), color-stop(46%,rgba(229,235,238,1)), color-stop(65%,rgba(215,222,227,1)), color-stop(100%,rgba(245,247,249,1))); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top,  rgba(246,248,249,1) 0%,rgba(229,235,238,1) 46%,rgba(215,222,227,1) 65%,rgba(245,247,249,1) 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top,  rgba(246,248,249,1) 0%,rgba(229,235,238,1) 46%,rgba(215,222,227,1) 65%,rgba(245,247,249,1) 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top,  rgba(246,248,249,1) 0%,rgba(229,235,238,1) 46%,rgba(215,222,227,1) 65%,rgba(245,247,249,1) 100%); /* IE10+ */
    background: linear-gradient(to bottom,  rgba(246,248,249,1) 0%,rgba(229,235,238,1) 46%,rgba(215,222,227,1) 65%,rgba(245,247,249,1) 100%); /* W3C */
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f6f8f9', endColorstr='#f5f7f9',GradientType=0 ); /* IE6-9 */

    border-top-left-radius: 10px;
    border-bottom-left-radius:10px;
    border-top-right-radius: 10px; 
    border-bottom-right-radius:10px;

    position: absolute;
    top: 200px;
    left: 150px;
    width: 1000px;

    background-position:center;

    font-size: 26px;
    font-family: 'Conv_LITHOSPRO-REGULAR';

    box-shadow: 3px 5px 10px  #888888;      
}
#navbar ul {
    list-style-position:inside;
    padding-top: 10px;
}


#navbar ul li {     
        display: inline;
        padding:0 60px 0px 0px; 
        margin-bottom: 10px;
        list-style-type:disc;
    }


#navbar ul li.OP {
        padding-left: 40px;
}   

a:link {
  color: #EF174A;
  }

a:visited {
  color: #BF4100;
  }

a:hover {
  color: black;
  background-color:#D2D2D2;
  border-radius: 10px;
  }

a:active {
  color: #918FBC;
  } 

a {
    text-decoration:none;
}  

#navbar ul li.OP a {
    padding-left: 10px;
}
<img src="" align="absmiddle">

That will align the text to middle of the image. 这将使文本与图像中间对齐。

or you could do it with css: 或者您可以使用CSS来做到这一点:

.your_class {
    vertical-align:middle;
} 

Give the text line-height equal to the height of the bar. 使文本的行高等于条形的高度。

a.yourtext { line-height: 44px }

But take care of the paddings. 但是要注意填充物。

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

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