Well I have this code which is fairly simple and should set margin-top of HTML 5’s button element to 1px when it is active ( mouse clicked on it). But what I get is a messed up layout, because the button does what it should do only it does it for both of the buttons which are right next to each other. Can you tell me what is causing this error to occur?
Here is a sample HTML code (because i cant just link to jsfiddle), but the link to jsfiddle is right at the bottom
<header id="main_header"> <!-- this is your header with logo, menu, login and get started now buttons -->
<div id="header_accent"></div> <!-- small accent image, barely seen on top of the page -->
<div id="header_holder"> <!-- this guy centers the header to the middle of the page's width -->
<img src="images/logo.png" alt="ssl8.com" id="logo"/> <!-- logo image -->
<div id="nav_holder"> <!-- positions the navigation and buttons -->
<nav>
<ul> <!-- navigation -->
<li class="active"><a href="#">prices</a></li>
<li><a href="#">features</a></li>
<li><a href="#">contact</a></li>
</ul>
</nav>
<button class="login">login</button> <!-- login button -->
<button class="getStartedNow">Get started now</button> <!-- get started now button -->
</div>
<div id="header_shadow"></div> <!-- holds the background shadow for the header (in CSS file) -->
</div>
</header> <!-- END of header -->
Here is jsfiddle.Ignore missing pictures etc, just click on the orange button and you will see what i am talking about.
Thank you
Here is my solution http://jsfiddle.net/burn123/emfwA/16/
What I Changed
opacity,box-shadow,transitions, andborder-radiusset for the buttons set on both buttons, which is redundant. I changed it so that it would apply to all buttonsbox-shadoworborder-radiusactiveandhoverpseudo elementtop: 1pxmin-width:100%so that the line will go all the way acrossThe main problem was coming from the fact that your buttons were set at a position of static, so by applying a
margin-topof1px, you were shifting the entire top down. By setting a position of relative, you can add properties such astoporleftand it will move the element in that direction while still keeping the space of the element in the same position