user1478985
user1478985

Reputation: 33

Stop text from moving on a:hover with border top

I have a floated an h2 a tag with a 6px border-top applied on hover. When I hover over the text it pushes the text and elements below it down. How can I stop the border from moving the text and other elements? Thanks!

My CSS:

html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
  border: 0;
  font-size: 100%;
  font: inherit;
  margin: 0;
  padding: 0
}

article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
  display: block
}

body {
  line-height: 1
}

ol, ul {
  list-style: none
}

blockquote,
q {
  quotes: none
}

blockquote:before,
blockquote:after,
q:before,
q:after {
  content: none
}

table {
  border-collapse: collapse;
  border-spacing: 0
}

.container {
  width: 960px;
  margin: 0px auto;
}

.logo {
  float: left;
  clear: both;
  margin-top: 30px;
}

body {
  background-image: url("../images/bg.jpg");
  border-top: 8px solid black;
}

h2 a {
  font-family: arial;
  text-decoration: none;
  text-transform: uppercase;
  font-size: 94px;
  color: black;
  float: right;
  margin: 0px;
  padding-top: 20px;
}

h2 a:hover {
  border-top: 6px solid orange;
  padding-top: 0px;
}

.clocknotes {
  width: 437px;
  margin: 0px auto;
  clear: both;
}

.brand-three {
  clear: both;
  margin-top: 85px;
}

.brand-three {
  font-size: 200px;
  line-height: 140px;
  float: left;
  letter-spacing: -20px;
}

.quote {
  clear: both;
  width: 417px;
  float: right;
  text-align: right;
  margin-top: -250px;
  font-size: 26px;
}

.social {
  clear: both;
  float: right;
  margin-top: -80px;
}

.footer {
  clear: both;
  top: 50px;
  position: relative;
}

Upvotes: 3

Views: 15678

Answers (3)

Ahsan Rathod
Ahsan Rathod

Reputation: 5505

CSS:

h2 a:hover {
    border-top: 6px solid orange;
    padding-top:14px;

}

DEMO: http://jsfiddle.net/rathoreahsan/VyRZW/

Upvotes: 15

Nikola Bogdanović
Nikola Bogdanović

Reputation: 3213

Reduce top padding for an equal amount, not to zero:

h2 a:hover {
border-top: 6px solid orange;
padding-top: 14px;
}

Upvotes: 3

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167240

Give this code:

h2 a {border-top: 6px solid #fff;} /* Should match your background color */

Upvotes: 0

Related Questions