newcoder1010 Posted January 30, 2016 Share Posted January 30, 2016 Hi, Below margin-left and margin-right auto is not working. I just want to put the logo in the center. Can you help? <section id="block-block-13" class="block block-block M-logo col-md-12 col-xs-12 contextual-links-region clearfix"> <div class="contextual-links-wrapper contextual-links-processed"> <a class="contextual-links-trigger" href="#">Configure</a><ul class="contextual-links"><li class="block-configure first last"> <a href="/dcyacht/?q=admin/structure/block/manage/block/13/configure&destination=node/49">Configure block</a></li></ul> </div> <a class="M-logo-a" href="/" title="Home"> <img src="sites/img/Mobile-DC-Yacht-Logo.png" alt="Home"> </a> </section> CSS: .M-logo .M-logo-a { margin-left: auto; margin-right:auto; width:200px; } Thanks. Link to comment Share on other sites More sharing options...
dsonesuk Posted January 30, 2016 Share Posted January 30, 2016 Its a inline element, width/height does not work with inline elements, only block elements so use display: block; or inline-block; Link to comment Share on other sites More sharing options...
newcoder1010 Posted January 30, 2016 Author Share Posted January 30, 2016 (edited) I am not understanding. I am trying to put the logo in the center. How display: block will put the logo in the center? Margin-left:10px; works but auto does not work. Edited January 30, 2016 by newcoder1010 Link to comment Share on other sites More sharing options...
newcoder1010 Posted January 30, 2016 Author Share Posted January 30, 2016 (edited) If you could visit my site. Please make sure the screen less than 768px. This is for mobile. http://godrupal.info/dcyacht/ Edited January 30, 2016 by newcoder1010 Link to comment Share on other sites More sharing options...
dsonesuk Posted January 30, 2016 Share Posted January 30, 2016 A ANCHOR 'a' as in <a class="M-logo-a" href="/" title="Home"> <img src="sites/img/Mobile-DC-Yacht-Logo.png" alt="Home"></a> IS A INLINE ELEMENT, INLINE ELEMENTS DO NOT TAKE HEIGHT OR WIDTH, YOU NEED A WIDTH TO USE MARGIN-LEFT: AND MARGIN-RIGHT AUTO. THEREFORE IT WILL NOT WORK. IT JUST ACTS AS TEXT WOULD, TO CENTER TEXT YOU WOULD USE TEXT-ALIGN: CENTER; ON THE PARENT BLOCK ELEMENT. Link to comment Share on other sites More sharing options...
newcoder1010 Posted January 30, 2016 Author Share Posted January 30, 2016 Many thanks. Now it worked. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now