I made a menu and for some odd reason, I can't figure out why, they bounced out of their positions... Can someone tell me why this is going on? I'll post my source code if needed.

Thanks

Dani AI

Generated

Quick diagnosis for based on the thread: the purple color is the browser’s visited-link color being applied by the cascade, and the 1px gap is failing because top does nothing on position: static. Check computed styles in DevTools to see which rule wins (color, specificity and rule order matter). was right that the visited state is involved; ’s grouping tip helps with keeping selectors consistent, but you still need the correct cascade and placement.

Practical fixes to try (do these in order):

  • Inspect the anchor in DevTools and find the rule that sets the purple color. Make your overriding rule at equal or higher specificity and place it later in the stylesheet.
  • Remove the top offsets from the menu item rules (they’re ignored for position: static). Use margin or a sibling selector to make a 1px gap, and make the anchor itself fill the item so the whole row is clickable.

Example structure and minimal CSS pattern to apply (add a single reusable class to each item rather than many IDs):

/* give each item a gap and consistent height */
#apDiv7 > .menu-item { margin: 0 0 1px 0; height: 26px; }

/* make the link fill the item and align text */
#apDiv7 > .menu-item > a { display: block; padding-left: 10px; line-height: 26px; text-decoration: none; }

Extra tips: use semantic markup (ul/li), avoid repeating the same gradient rules on multiple IDs (use a class), and keep your link pseudo-class rules in a clear order so the cascade is predictable. For reference on why top is ignored when position is static, and on visited-link styling, see the MDN docs: position and :visited.

Recommended Answers

All 6 Replies

You gave no info that can be analysed. Please post the code with problem, and if possible a test page or upload to jsfiddle.net.

yes, go ahead and post the source code for more help.

Well I fixed the "bouncing" issue, not I have an issue in color... why do they show up purple... and how come I can't create a 1px space between each tab?
Here is my code:

Css:

#apDiv7 {
    position:absolute;
    overflow:auto;
    width:200px;
    height:115px;
    z-index:1;
    left: 6px;
    top: 6px;
    background-color: #5c6063;
}
#apDiv8 {
    position: static;
    width:200px;
    height: 26px;
    z-index:1;
    font-size: 11px;
    color: #FFF;
    background: #636363; /* Old browsers */
    background: -moz-linear-gradient(top, #2b2a2a 0%, #000000 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#2b2a2a), color-stop(100%,#000000)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, #2b2a2a 0%,#000000 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, #2b2a2a 0%,#000000 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top, #2b2a2a 0%,#000000 100%); /* IE10+ */
    background: linear-gradient(to bottom, #2b2a2a 0%,#000000 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2b2a2a', endColorstr='#000000',GradientType=0 ); /* IE6-9 */        
}
a:link {
    color: #FFF;
    text-decoration:none;
    line-height: 25px;
    position: relative;
    left: 10px;
 }
a:hover {
    color: #3780c3;
    line-height: 25px;
    left: 10px;
    text-decoration: none;
}
#apDiv9 {
    position: static;
    width:200px;
    height: 26px;
    z-index:2;
    top: 29px;
    font-size: 11px;
    color: #FFF;
    background: #636363; /* Old browsers */
    background: -moz-linear-gradient(top, #2b2a2a 0%, #000000 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#2b2a2a), color-stop(100%,#000000)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, #2b2a2a 0%,#000000 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, #2b2a2a 0%,#000000 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top, #2b2a2a 0%,#000000 100%); /* IE10+ */
    background: linear-gradient(to bottom, #2b2a2a 0%,#000000 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2b2a2a', endColorstr='#000000',GradientType=0 ); /* IE6-9 */        
}
#apDiv10 {
    position: static;
    width:200px;
    height:26px;
    z-index:3;
    font-size: 11px;
    top: 59px;
    color: #FFF;
    background: #636363; /* Old browsers */
    background: -moz-linear-gradient(top, #2b2a2a 0%, #000000 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#2b2a2a), color-stop(100%,#000000)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, #2b2a2a 0%,#000000 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, #2b2a2a 0%,#000000 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top, #2b2a2a 0%,#000000 100%); /* IE10+ */
    background: linear-gradient(to bottom, #2b2a2a 0%,#000000 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2b2a2a', endColorstr='#000000',GradientType=0 ); /* IE6-9 */        

}
#apDiv12 {
    position: static;
    width:200px;
    height:26px;
    z-index:4;
    top: 87px;
    font-size: 11px;
    color: #FFF;
    background: #636363; /* Old browsers */
    background: -moz-linear-gradient(top, #2b2a2a 0%, #000000 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#2b2a2a), color-stop(100%,#000000)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top, #2b2a2a 0%,#000000 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top, #2b2a2a 0%,#000000 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top, #2b2a2a 0%,#000000 100%); /* IE10+ */
    background: linear-gradient(to bottom, #2b2a2a 0%,#000000 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2b2a2a', endColorstr='#000000',GradientType=0 ); /* IE6-9 */
}

HTML:

<div id="apDiv7">
    <div id="apDiv8"><a href="http://google.com">1</a></div>
    <div id="apDiv9"><a href="http://amazon.com">2</a></div>
    <div id="apDiv10"><a href="http://facebook.com">3</a></div>
    <div id="apDiv12"><a href="http://twitter.com">4</a></div>
  </div>

But thanks you guys for responding quickly!

They show up purple because that's the default color that your browser is applying to a visited link. If you want to override those default properties, you need to apply additional CSS.

for example,

a:link {color:#FFFFFF;}       /* unvisited link  */
a:visited {color:#FFFFFF;}    /* visited link    */
a:hover {color:#FFFFFF;}      /* mouse over link */
a:active {color:#FFFFFF;}     /* selected link   */

On my browser, they would always show up blue... they never turned purple like it did recently... and I did try your snippets of code, i still got no change in color...

Try this:

a, a:link, a:hover, a:active, a:visited {
    color: #fff;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.