Hover over an element that will take effect in another - html

I have the following code:
.tratoresList h3{
font-family: "opensans-light-webfont";
font-size: 17px;
color: #000;
width: 210px;
text-align: center;
}
.tratoresList strong{
font-family: "opensans-extrabold-webfont";
font-size: 17px;
color: #000;
width: 210px;
}
.tratoresList strong, .tratoresList h3:hover{
font-family: "opensans-extrabold-webfont";
font-size: 17px;
color: #a80000;
width: 210px;
}
And here is the HTML, can someone say me what is wrong?
<ul class="margin-top-50 tratoresList">
<li>
<img src="./imagens/trator1.png" />
<h3>linha <strong>4000</strong></h3>
<div class="tratoresListArrow"></div>
</li>
When I hover within the h3 he has to do the hover also in strong and vice versa.
What did I do wrong?

.tratoresList h3{
font-family: "opensans-light-webfont";
font-size: 17px;
color: #000;
width: 210px;
text-align: center;
}
.tratoresList strong{
font-family: "opensans-extrabold-webfont";
font-size: 17px;
color: #000;
width: 210px;
}
.tratoresList h3:hover, .tratoresList h3:hover ~ strong{
font-family: "opensans-extrabold-webfont";
font-size: 17px;
color: #a80000;
width: 210px;
}
<div class="tratoresList">
<h3>CSS - HOVER AN ELEMENT THAT WILL TAKE EFFECT IN ANOTHER</h3>
<strong>I THINK ITS POSSIBLE NOW !</strong>
</div>
I hope it helps you....

You cannot do this in CSS3 unless the strong element can be specified in the same selector as h3:hover (right now, this only works when the strong element is an sibling), however otherwise you cannot do "disjoint" effects using pure CSS, you must use scripting. Here's a quick example (that doesn't use jQuery for once). I haven't tested it - it might work, it might not. Have fun!
document.querySelectorAll(".tratoresList h3")forEach( function(el1) {
el1.addEventListener("mouseover", function() {
document.querySelectorAll(".tratoresList strong").forEach( function(el2) {
el2.classList.toggleClass("hoverEffect");
} );
});
} );

If you want to change the style of text in strong tags(inside h3) when you hover over h3..
.tratoresList h3:hover strong{
color: green;
}}

Related

Two lined button with different font sizes?

`Hi, I'd like to make a button with two lines of text and have them in different font sizes... Is there any way? My current way was trying it with an kind of designed button. Could that work in some way? Any help is appreciated! Beneath you see what I'm working with right now... I want to have a second line under "START" which is displayed in a much smaller font size
<a class="smallbtn">START</a>
.smallbtn {
font-family: "Lato Light";
background-color: #58B947;
border-radius:5px;
color: white;
padding: 15px 6px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 21px;
width: 73%;
cursor: default;
margin-bottom: 5px;
}
you could do this if you just want to add a new line of text under your "START"
<a class="smallbtn">START<br><sub>hello</sub></a>
or
p{
font-size:12px;
padding:0px;margin:0px;}
<a class="smallbtn">START<br><p>hello</p></a>
You can try insert a div inside the button, give an id to the element and add css, like this:
<a class="smallbtn">START<div id="smallbtnFont">hello</div></a>
#smalbtnFont{
font-family: "arial";
font-size: 1em;
}
good question, heres how:
button {
font-family: "Lato Light";
background-color: #58B947;
border-radius:5px;
color: white;
padding: 15px 6px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 21px;
width: 73%;
cursor: default;
margin-bottom: 5px;
}
<button>Start<br><small style="font-size:50%;">Now</small></button>

css class with span not recognizing hover

I am trying to get a link to be half one color and half another color, then switch upon hover. So: (white)Hello (Blue)Everyone! -> (Blue)Hello (White)Everyone!
I think I may have dumbed down the code too much... this is a better example.
How do I get it to where "EVERYONE!" does not have a box around it?
HTML:
<div class="home-logo-text">
<a href="#">
HELLO
<span class="home-logo-text-roads">
EVERYONE!
</span>
</a>
</div>
CSS:
.home-logo-text a {
font-family: 'Oswald', sans-serif;
font-size: 60px;
font-weight: 700;
text-transform: uppercase;
position: relative;
margin-bottom: 0px;
text-align: center;
line-height: 1;
padding: 5px 25px 0;
border: 5px solid;
color: #808080;
}
.home-logo-text-roads {
font-family: 'Oswald', sans-serif;
font-size: 60px;
font-weight: 700;
text-transform: uppercase;
position: relative;
margin-bottom: 0px;
text-align: center;
line-height: 1;
padding: 5px 25px 0;
border: 5px solid;
color: #6698cb;
}
.home-logo-text.light a {
color: rgba(255,255,255,0.9);
}
.home-logo-text a:hover {
color: #6698cb;
}
.home-logo-text a:hover .home-logo-text-roads {
color: #808080;
}
a:hover .home-logo-text-roads {
color: #ffffff;
}
Your last CSS rule doesn't look right:
.home-logo-text-roads a:hover {
color: #ffffff;
}
This CSS says "for an <a> element sitting inside a .home-logo-text-roads element, when it gets hover change its text color to #ffffff. Which is clearly not what you wanted, since you have no <a> element inside your span. If you want to change the span's color on hover event of the <a> which is its parent, switch the selectors around:
a:hover .home-logo-text-roads {
color: #ffffff;
}
Remember when there's a space between selectors it indicates a fuzzy hierarchy and the rules are applied to the element to the far right.
You need this. Use whatever color you want.
.home-logo-text a:hover .home-logo-text-roads {
color: #707070;
}
Check DEMO here.
Put the correct order of the HTML elements so CSS styles will be applied:
.home-logo-text a {
color: #707070;
}
.home-logo-text-roads {
color: #6698cb;
}
.home-logo-text a:hover {
color: #6698cb;
}
.home-logo-text a:hover .home-logo-text-roads {
color: #ffffff;
}

Blue underline in the middle of a div

I have a blue underline that I'm having trouble removing.
I'm pretty sure that it is either a border:none or text-decoration:none problem, but I can't seem to find the solution.
Here is a screenshot of my problem:
HTML:
<a href="#top"><div class="content_tab" id="first_tab">
<span class="tab_text_centred">Back to top</span>
</div></a>
CSS:
.content_tab {
width: 220px;
height: 340px;
margin-right: 0px;
margin-bottom: 20px;
float: left;
background-color: #000;
overflow: hidden;
color: #FFF;
font-family: Georgia, Times ,serif;
font-size: 30px;
font-style: italic;
}
#first_tab {
background-color: #1b1c20;
text-align: center;
}
.tab_text_centred {
position:relative;
top:153px;
}
JSFIDDLE: http://jsfiddle.net/craigzilla/DptMf/
A tag have the default property display:inline.
DIV tag have defaut property: display:block.
A tag wrap DIV tag is not incompatible with W3C.
With your case, it can be more simple as below:
HTML code:
<a href="#top" class="content_tab" id="first_tab">
<span class="tab_text_centred">Back to top</span>
</a>
CSS code:
.content_tab {
width: 220px;
height: 340px;
line-height: 340px;
margin-right: 0px;
margin-bottom: 20px;
float: left;
background-color: #000;
overflow: hidden;
color: #FFF;
font-family: Georgia, Times ,serif;
font-size: 30px;
font-style: italic;
}
#first_tab {
background-color: #1b1c20;
text-align: center;
}
You can not put a tags around a div in pre-HTML5. This is not how you make a div and it's contents link clickable in pre-HTML5. It seems your issue could be connected to a text decoration issue caused by the use of this tag in this manner. Ensure you adopt the correct way for HTML 4.01 or keep it as you have but ensure you use the correct declaration in the head of your document.
I don't see anything but make sure you haven't got anything underlined by doing the following, then try again.
a, a:focus, a:active, a:hover, a:visited {
text-decoration:none;
}
I don't see the line in your fiddle using Chrome, but that's a lot of extra markup.
http://jsfiddle.net/DptMf/2/
Back to top
.content_tab {
width: 220px;
height: 340px;
line-height:340px;
margin-right: 0px;
margin-bottom: 20px;
float: left;
background-color: #000;
text-decoration:none;
overflow: hidden;
color: #FFF;
font-family: Georgia, Times ,serif;
font-size: 30px;
font-style: italic;
}
#first_tab {
background-color: #1b1c20;
text-align: center;
}
Is putting a div inside an anchor ever correct?
As specified by another person:
'You can not put a tags around a div. This is not how you make a div and it's contents link clickable.
This applies to pre-HTML5, and support for a tags is low. I think it's a text decoration issue caused by this action.

CSS breadcrumbs Help formatting fonts

I am having some difficulty changing font color decoration ect across the same DIV tag.
What I want to do is make a breadcrumb type navigation on certain pages in my site and I would like to minimize the amount or Div's I use so as to make it easier to maintain.
here is what I have and would like to do.
<div id="product-breadcrumbs">
<div id="breadcrumbs">(Link and color) // (another link and another color)
</div>
</div>
CSS
#product-breadcrumbs {
position: absolute;
left: 0px;
top: 66px;
width: 1024px;
height: 34px;
background-color: #E7E5F2;
}
#breadcrumbs {
position: relative;
padding-top: 7px;
padding-bottom: 7px;
text-align: left;
text-indent: 140px;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 14px;
font-weight: bold;
color: #09C;
text-decoration: none;
}
Edit: Reread your question (you are right, I did misread it). You could accomplish this by giving classes to your links, no?
<div id="product-breadcrumbs">
<div id="breadcrumbs">
A link
Another link
</div>
</div>
with the following CSS:
#breadcrumbs a.colorOne {
color: black;
}
#breadcrumbs a.colorTwo {
color: blue;
}

i want to change the color when the mouse is over and return it when it leave (html)?

what i have to write in onmouseover to change the background color of <td> in the topic_name class:
<td dir="rtl" class="topic_name" onmouseOver=""><\td>
this is topic_name class:
.topic_name {
font-family: tahoma;
font-size: 10pt;
font-weight: bold;
text-transform: capitalize;
color: #FFFFFF;
text-align: center;
background-color: #627AAD;
padding: 0cm;
margin: 0px;
width: 255px;
height: 35px;
cursor: pointer;cursor=hand;
}
Use the CSS hover selector
.topic_name:hover{
background-color:yellow;
}
See example
onMouseover="this.style.backgroundColor='#000';" onMouseout="this.style.backgroundColor='#627AAD';
You can always use a library like jQuery and make your life easier ;)