简体   繁体   English

HTML和CSS3菜单问题

[英]HTML and CSS3 menu questions

Thank you for reading my question. 感谢您阅读我的问题。

I still have a lot to learn regarding HTML and CSS, yet I'm trying. 关于HTML和CSS,我还有很多要学习的东西,但是我正在尝试。 However, this brought me to a problem (I searched around a bit, but couldn't find a good answer): 但是,这给我带来了一个问题(我进行了一些搜索,但找不到一个好的答案):

I want to make a menu on the top of my page, as header. 我想在页面顶部制作一个菜单,作为标题。 However, in the middle of this menu there is an image, as logo. 但是,在此菜单的中间有一个图像,如徽标。 Failing to get them next to each other correctly, I used them in a list 未能正确地使它们彼此相邻,我在列表中使用了它们

    <div class="wrap_header">
<ul>
    <li><a href="#">MENU ITEM 1</a></li>
    <li><a href="#">MENU ITEM 2</a></li>
    <li id="header logo"><img src="the image"></li> 
    <li><a href="#">MENU ITEM 3</a></li>
    <li><a href="#">MENU ITEM 4</a></li>
</ul>
</div><!--END wrap_header-->

Here I'm stuck: - I want the 'MENU ITEM 1-4' to be almost at the middle(height) of the image. 我被困在这里:-我希望“菜单项1-4”几乎位于图像的中间(高度)。 However the image has to stay were it is(so be at the very center, just at the bottom). 但是图像必须保持原样(因此要在最中央,在最底部)。 If possible being able to change its position too if needed. 如果可能,也可以根据需要更改其位置。 - I want the 'MENU ITEM 1-4' to be underlined by a 2px high,colored line, not sure how to do that. -我想在'MENU ITEM 1-4'(菜单项1-4)的下面加2px高的彩色线,不知道该怎么做。 It'll have to look something like this: 它必须看起来像这样:

empty space                   THE IMAGE
MENU ITEM 1    MENU ITEM 2    THE IMAGE    MENU ITEM 3    MENU ITEM 4
empty space                   THE IMAGE

I'm not sure whether I understood the question. 我不确定我是否理解这个问题。 But to my answer would be: 但是我的答案是:

<div class="wrap_header">
<ul>
    <li><a href="#">MENU ITEM 1</a></li>
    <li><a href="#">MENU ITEM 2</a></li>
    <li id="header_logo"><img src="http://www.prskelet.com/images/logotip.jpg"/></li> 
    <li><a href="#">MENU ITEM 3</a></li>
    <li><a href="#">MENU ITEM 4</a></li>
</ul>
</div><!--END wrap_header-->

And style it like so: 并使其样式如下:

    ul li{
            margin-right:20px;
            line-height:200px;
            float:left;
    } 
    ul li img{
            height:200px;
            width:auto; 
   }
   ul li a {
            text-decoration:none;
            border-bottom:2px solid red;
   }

You need to put line height equal to the image height and then vertically align it. 您需要将线高设置为等于图像高度,然后将其垂直对齐。 To underline text with a color you chose you will need to add border-bottom . 要在您选择的颜色下划线,您需要添加border-bottom Here you can see jsFiddle 在这里您可以看到jsFiddle

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

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