user5832968
user5832968

Reputation:

a href style inheriting

I am having an issue where my navigation a is conflicting with an a href on .content - I have been trying to tackle this for the last few hours and no luck, thanks.

ul.nav {
    list-style-type: none;
    margin: 0;
    min-width: 360px;
}
ul.nav li {
    display: table-cell;
    text-align: center;
}
a.active {
    background-color: #cc293f;
    font-weight: 700;
}
.nav-container {
    font-family: 'Catamaran', sans-serif;
    background-color: #505050;
    margin: 5px 0 0;
}
.table {
    display: table;
    margin: 5px auto;
}
a {
    font-family: 'Catamaran', sans-serif;
    background-color: #505050;
    border-right: 1px solid #fff;
    color: #fff;
    float: left;
    padding: .2em .6em;
    text-decoration: none;
    width: 10em;
}
a:hover {
    background-color: #cc293f;
}
.content {
    border-radius: 10px 10px 10px 10px;
    border: 2px solid #cc293f;
    margin-top: 10px;
    min-width: 360px;
    min-height: 650px;
}
.content h1 {
    font-size: 26px;
    color: #fff;
    text-align: center;
    margin-top: 5px;
}
.content h2 {
    font-size: 22px;
    text-align: center;
    margin-top: -35px;
}
.content p {
    font-size: 18px;
    margin-top: -5px;
    margin-left: 10px;
}
.content #p2 {
    font-size: 19px;
    margin-left: 50px;
    margin-top: -5px;
}
<html>
<body>
<div class="nav-container">
<div class="table">
<ul class="nav">
<li style="border-left:1px solid white;"><a class="active" href=
    "index.html">Home</a></li>
<li><a href="faq.html">FAQs</a></li>

<li><a href="support.html">Resolution Center</a></li>
<li><a href="upload.html">Upload</a></li></ul>
</div>
  </div>

<div class="content">

<p>example</p>
<a href="google.com" target="_blank"><img src="http://cumbrianrun.co.uk/wp-content/uploads/2014/02/default-placeholder.png" height="75" width="75"></a>

</body>
</html>

Upvotes: 1

Views: 388

Answers (2)

Dragos Sandu
Dragos Sandu

Reputation: 664

You declare style for global <a> tag, so all <a tags will use that style. Special style for <a tags from .content class can be achieved by adding to your css file: .content a { your instructions }.

Furthermore, use ul nav li a to specify your desired options for the menu. If you have multiple ul list in your project, use a specific class for each of them.

Upvotes: 1

damiano celent
damiano celent

Reputation: 709

See this now has very different properties on default and hover.

ul.nav {
    list-style-type: none;
    margin: 0;
    min-width: 360px;
}
ul.nav li {
    display: table-cell;
    text-align: center;
}
a.active {
    background-color: #cc293f;
    font-weight: 700;
}
.nav-container {
    font-family: 'Catamaran', sans-serif;
    background-color: #505050;
    margin: 5px 0 0;
}
.table {
    display: table;
    margin: 5px auto;
}
a {
    font-family: 'Catamaran', sans-serif;
    background-color: #505050;
    border-right: 1px solid #fff;
    color: #fff;
    float: left;
    padding: .2em .6em;
    text-decoration: none;
    width: 10em;
}
a:hover {
    background-color: #cc293f;
}
.content {
    border-radius: 10px 10px 10px 10px;
    border: 2px solid #cc293f;
    margin-top: 10px;
    min-width: 360px;
    min-height: 650px;
}
.content h1 {
    font-size: 26px;
    color: #fff;
    text-align: center;
    margin-top: 5px;
}
.content h2 {
    font-size: 22px;
    text-align: center;
    margin-top: -35px;
}
.content p {
    font-size: 18px;
    margin-top: -5px;
    margin-left: 10px;
}
.content #p2 {
    font-size: 19px;
    margin-left: 50px;
    margin-top: -5px;
}
.content a {
 background:blue;
 transition:1s;
 }
 .content a:hover {
 transform:translateX(500px);background:red;
 }
<html>
<body>
<div class="nav-container">
<div class="table">
<ul class="nav">
<li style="border-left:1px solid white;"><a class="active" href=
    "index.html">Home</a></li>
<li><a href="faq.html">FAQs</a></li>

<li><a href="support.html">Resolution Center</a></li>
<li><a href="upload.html">Upload</a></li></ul>
</div>
  </div>

<div class="content">

<p>example</p>
<a href="google.com" target="_blank"><img src="http://cumbrianrun.co.uk/wp-content/uploads/2014/02/default-placeholder.png" height="75" width="75"></a>

</body>
</html>

Upvotes: 0

Related Questions