简体   繁体   中英

center align the text in menu item

I am working this site My Site The primary menu item Post An Ad has a red color background to it.Primary Menu has a dashed border.as the Post an ad item Background is big and is touching the the primary menu border i have changed the css into this

.header_menu_res ul a.rb_btn_postanad {
background: #981817 url(images/rb_btn_addnew.png) no-repeat 23px 23px;
padding-left: 50px;
padding-right: 30px;
font-weight: bold;
font-size: 20px;
line-height: 20px;
margin-left: 20px;
border-right: 1px solid #831617;
border-left: 1px solid #831617;
color: #fff;
height: 10px;
margin-top: 5px;
}

The css was actualy this

.header_menu_res ul a.rb_btn_postanad {
background: #981817 url(images/rb_btn_addnew.png) no-repeat 23px 23px;
padding-left: 50px;
padding-right: 30px;
font-weight: bold;
font-size: 20px;
line-height: 20px;
margin-left: 20px;
border-right: 1px solid #831617;
border-left: 1px solid #831617;
color: #fff;
    }

I added

height: 10px;
margin-top: 5px;

which gave me the desired result.But the problem now is the text inside is not inside the middle of the menu item.I have tried adding padding top but it didn't help. Can anyone please help me in making it in the middle of the menu item.Thanks!!

Change your class css to followings

.header_menu_res ul a.rb_btn_postanad {background: #981817 url(images/rb_btn_addnew.png) no-repeat 23px 17px;
line-height: 11px;}

I checked this solution and it works.
Hope this will help you.

You should add this css to your css

.header_menu_res ul a.rb_btn_postanad {background: #981817 url(images/rb_btn_addnew.png) no-repeat 23px 17px;
line-height: 11px;}

This will work for you. Also change for hover class similar to above.

You simply forgot the top/bottom padding then you need to update the plus icon's position.

.header_menu_res ul a.rb_btn_postanad {
    background: #981817 url(images/rb_btn_addnew.png) no-repeat 23px 18px;
    padding-left: 50px;
    margin: 5px 0 0 20px;
    padding-right: 15px 30px 15px 50px;
    font-weight: bold;
    font-size: 20px;
    line-height: 20px;
    border-right: 1px solid #831617;
    border-left: 1px solid #831617;
    color: #fff;
}

Add these:

.header_menu_res ul li {
    display: table;
}

a.rb_btn_postanad {
    display: table-cell;
    vertical-align: middle;
}

That will work.

Hi remove this attribute:

.header_menu_res ul a.rb_btn_postanad
  {
    margin-top:0px;
    height:10px;
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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