Jump to content
newcoder1010

How to place the logo in the center of anchor

Recommended Posts

Hello,

HTML:

<a class="logo navbar-btn pull-left" href="/" title="Home">
          <img src="/sites/default/files/mmmo_0.jpg" alt="Home">
        </a>

My CSS

.logo {text-align:center;}

Currently, image is floated to left I guess because of bootstrap default  pull-left class. When I click on a class in chrome inspect, I get this css:

 
.navbar .logo {
 margin-right: -15px;
 padding-left: 15px;
 padding-right: 15px;
}
.pull-left {
 float: left !important;
}
I wont be able to change any html classes. How can I place the logo in the center of logo class?
 
Thanks.

 

 

Share this post


Link to post
Share on other sites

You'll have to override the float rule using the !important declaration. Then you can center the link by setting the text-align property of the .navbar element.

Share this post


Link to post
Share on other sites

The anchor needs to become a block element if it is not already so, for text-align: to work, and float: none !important; used

.navbar .logo.navbar-btn.pull-left {display: block; float: none !important;}

This along with your current .logo class, IF the img is still inline or inline-block should centre as it would for text.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...