Set hover on the link inside a class - html

I'm trying to set a :hover for a link inside a class. At first I tried
.link{
color: #e62739;
}
I saw past discusssion and try the solution proposed
.opener a.link:hover {
color: #e62739;
}
but it didn't work. Im'not sure to know where is my mistake.
.link{text-decoration:none; color:white;}
.opener a.link:hover {
color: #e62739;
}
.row {
display: flex; /* equal height of the children */
}
.col {
flex: 1; /* additionally, equal width */
padding: 1em;
border: solid;
}
div {font-family:'Varela Round';
}
.opener {
background-color: #07183d;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
border: 1px white solid;
}
.benefits {
background-color: #07183d;
border: none;
color: white;
padding: 15px 32px;
text-decoration: none;
display: inline-block;
font-size: 16px;
width:300px;
}
a {
text-decoration: none;
}
#upbutton {
border: 1px dotted white;
}
<div class="row">
<div class="opener col" style="padding-left: 10px;padding-right: 10px;"><a class="link" href="www.google.com" name="1" onclick=" show('1');" style="color: white;font-size: 14px;">SOCIETES: 400</a>
<div class="benefits" id="b1" style="display: none; color: white; font-size: 14px;">Part SBF 120 : 120<br />
Part Filiales +100M€: 280
<div id="upbutton"><a onclick=" hide('1');">fermer</a></div>
</div>
</div>

The issue is the inline styling you've got on the link: color: white;.
This is taking priority over any styling you're adding in your CSS file. Removing that from the inline styling allows the hover color to work.
If you need the white color by default add it to the stylesheet rather than inline. For example:
.link {
color: white;
}

Related

how to make color change to white when hovering over button

The text color only changes when I hover over the text. I want the text color to change to white when I hover over the button.
Can anyone see where I am going wrong, please?
#callbtn {
border: 1px solid #507487;
background-color: white;
padding: 10px;
font-size: 20px;
color: #507487;
border-radius: 10px;
font-weight: bold;
text-align: center;
}
#callbtn:hover {
background-color: orange;
color: white;
border: 1px solid orange;
cursor: pointer;
}
#callbtn a {
color: #507487;
}
#callbtn a:hover {
color: white;
}
#media screen and (max-width: 768px) {
#callbtn {
font-size: 14px;
}
}
#callbtn i {
padding-right: 10px;
}
<p class="m-2 text-center" id="callbtn"><i class="fas fa-phone-volume"></i>Call</p>
Your CSS need to apply the color on hover of the button, not the hover of the link
#callbtn:hover a {
color: #FFF
}
callbtn:hover triggering when the button is hovered over, and a:hover is triggering when the link is hovered over. Which is why this is happening, you are hovering over the button but not setting the colour of the link. The CSS below will set a style to the child link when button is hovered over.
#callbtn:hover a {
color: white;
}
It would be more efficient to set your button up like this:
.callbtn {
display: block;
border: 1px solid #507487;
background-color: white;
color: #507487;
padding: 10px;
text-decoration: none;
border-radius: 10px;
text-align: center;
font-weight: bold;
font-size: 20px;
}
.callbtn:hover {
border: 1px solid orange;
background-color: orange;
color: white;
}
.callbtn i {
padding-right: 10px;
}
#media screen and (max-width: 768px) {
.callbtn {
font-size: 14px;
}
}
<link href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" rel="stylesheet"/>
<a class="callbtn" href="tel:+441225xxxxxx">
<i class="fas fa-phone-volume"></i>Call
</a>
It's a bit weird but some JavaScript solves the problem:
var callButton = document.body.querySelector("#callbtn");
var callButtonLnk = document.body.querySelector("#callbtn a");
callButton.addEventListener("mouseover", function(){
callButtonLnk.style.color = "white";
})
callButton.addEventListener("mouseout", function(){
callButtonLnk.style.color = "#507487";
})

Linking to a page via a button with an href isn't working

When I put a button tag on "sign up" it doesn't take me to the page I set up, but when I remove the button tag, it works.
Buttons with href won't work. Especially on the "sign up" button. But the other buttons are working. Does anybody know what the problem is?
.button {
background-color: #4CAF50;
/* Green */
border: none;
color: white;
padding: 16px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
width: 70px;
height: 30px;
-webkit-transition-duration: 0.4s;
/* Safari */
transition-duration: 0.4s;
cursor: pointer;
}
.button1 {
background-color: #ccd9ff;
color: black;
border: 2px solid #555555;
}
.button1:hover {
background-color: #808080;
color: white;
}
.button2 {
background-color: #ccd9ff;
color: black;
border: none;
}
.button2:hover {
background-color: ffcccc;
color: white;
}
.button3 {
background-color: #ccd9ff;
color: black;
border: none;
}
.button3:hover {
background-color: #ff99e6;
color: white;
}
.button4 {
background-color: #ccd9ff;
color: black;
border: none;
}
.button4:hover {
background-color: #ff9999;
}
.button5 {
background-color: #ccd9ff;
color: black;
border: none;
}
.button5:hover {
background-color: #ffb399;
color: white;
}
.button6 {
background-color: #ccd9ff;
color: black;
border: none;
}
.button6:hover {
background-color: #9999ff;
color: white;
}
.button7 {
background-color: #ccd9ff;
color: black;
border: none;
}
.button7:hover {
background-color: #ccccff;
color: white;
}
.button8 {
background-color: #ccd9ff;
color: black;
border: none;
}
.button8:hover {
background-color: #ffffcc;
color: white;
}
<form id="searchbox" action="">
<input id="search" type="text" placeholder="Search Anime">
<button class="button button1" id="submit" type="submit" value="Search">Search</button>
<FONT face="Comic Sans MS" COLOR="#ff4d4d" SIZE=2>Login</FONT> or
<A HREF=register.html style="text-decoration:none">
<button class="button button8" <FONT face="Comic Sans MS" COLOR="#ff4d4d" SIZE=2>Sign Up</FONT><Button>
</A>
</form>
you should close the anchor tag and use quotes around the link
my link
PS use lowercase for tag eg: <a> and attribute eg: href
Try
<input type="submit" class="button button8" value="Sign Up">
Style it via external CSS rather than inline.
I'd say that's because HTML doesn't work that way... I advise you to follow some W3C Tutorial.
Start off here: https://www.w3schools.com/tags/tag_button.asp
Anyway, the main problem I think it's that, in the DOM Tree, you can't have inline elements (such as ) containing block elements (such as )
So with I'd add an onclick attribute, rather than putting the button inside an
Also, to be sure with HTML, always use this syntax:
Note the lowercase, and the quoting marks!

Remove blank spaces between buttons in HTML, CSS

I want to remove blank spaces between the buttons, so that when I for example hover over the NORMAL button, there will be no blank space between it and the HARD button. How can I do that and where do these blank spaces come from?
body {
margin: 0;
}
#stripe {
background-color: white;
text-align: center;
height: 50px;
color: black;
}
button {
border: none;
background: none;
text-transform: uppercase;
height: 100%;
font-weight: 700;
color: black;
letter-spacing: 1px;
font-size: inherit;
transition: all 0.3s;
outline: none;
}
button:hover {
color: white;
background: black;
}
.selected {
color: white;
background: black;
}
<div id="stripe">
<button class="mode">Easy</button>
<button class="mode">Normal</button>
<button class="mode selected">Hard</button>
</div>
Browsers always add spaces between some elements, including buttons. To remove these, you need to set font-size to zero for their parent container. Then, to restore text size inside buttons, set font-size for them.
#stripe {
font-size: 0;
}
button {
font-size: 14px; // Set font size that you need here
}
Either remove the spaces and carriage returns, or put an HTML comment between them.
body {
margin: 0;
}
#stripe {
background-color: white;
text-align: center;
height: 50px;
color: black;
}
button {
border: none;
background: none;
text-transform: uppercase;
height: 100%;
font-weight: 700;
color: black;
letter-spacing: 1px;
font-size: inherit;
transition: all 0.3s;
outline: none;
}
button:hover {
color: white;
background: black;
}
.selected {
color: white;
background: black;
}
<div id="stripe">
<button class="mode">Easy</button><!--
--><button class="mode">Normal</button><!--
--><button class="mode selected">Hard</button>
</div>
Add display: flex; to the parent container
If using bootstrap, can group buttons together by wrapping in div with class="btn-group".
Example for v3.3.7: https://getbootstrap.com/docs/3.3/components/#btn-groups-single
Visually might or might not be what you want. Has rounded corners on left and right ends and straight line between buttons. Can probably restyle.

How to make the middle of image and links on the same line?

Ok, I got this code
#container {
white-space: nowrap;
}
.linkButton:link,
.linkButton:visited {
background-color: white;
color: black;
border: 2px solid green;
padding: 7.5px 15px;
text-align: center;
text-decoration: none;
display: inline-block;
}
.linkButton:hover,
.linkButton:active {
background-color: green;
color: white;
}
<div id="container">
<img src="logo.png" />
<a href='index.jsp' class='linkButton'>Home</a>
</div>
Somehow the image and the link are not on the same line. Seem that the image is a bit higher than the link.
How to make the middle of the image & the middle of the link are on the same line (that means I want the middle "-" of "H" on the same line of the middle of the image)?
You can see the code here: https://jsfiddle.net/sersc0tf/2/
You can use Flexbox
#container {
display: flex;
align-items: center;
}
.linkButton {
background-color: white;
border: 2px solid green;
padding: 7.5px 15px;
text-align: center;
text-decoration: none;
}
<div id="container">
<img src="http://placehold.it/150x100">
<a href='index.jsp' class='linkButton'>Home</a>
</div>
Update: In this case only vertical-align: middle on img will work
.linkButton {
background-color: white;
border: 2px solid green;
padding: 7.5px 15px;
text-align: center;
text-decoration: none;
}
img {
vertical-align: middle;
}
<div id="container">
<img src="http://placehold.it/150x100">
<a href='index.jsp' class='linkButton'>Home</a>
</div>
You can play with the vertical-align property. In your case, I think that adding vertical-align: middle on both elements should work.

Hide/show text in body on hover of child element

I'd like to initially hide text in my body, but show it once an element in a child div is hovered over. So In this case, I want them both to initially start out as display: none but then when I hover over the letter "H" I want "Text A" to show. When I hover over letter "E" I want "Text B" to show. I don't want to put my #content elements inside of my #word elements. I want to keep them as separate divs.
Any Ideas?
(See Fiddle below)
HTML:
<div id="word">
<h1><a id="h" class= "letter" href=#>H</a></h1>
<h1><a id="e" class= "letter" href=#>E</a></h1>
<h1><a id="l" class= "letter" href=#>L</a></h1>
<h1><a id="l2"class= "letter" href=#>L</a></h1>
<h1><a id="o" class= "letter" href=#>O</a></h1>
</div>
<div id="content">
<div id="textA">Text A</div>
<div id="textB">Text B</div>
</div>
CSS:
body {
font-family: 'Chango', cursive;
font-size: 115px;
color: white;
text-shadow: 5px 5px 5px #000;
width: 100%;
height: 100%;
margin: 0px;
background: black;
}
#name {
position:absolute;
height:100%;
width: 70%;
display: table;
padding: 0 15% 0 15%;
background: black;
}
h1 {
display: table-cell;
vertical-align: middle;
text-align:center;
height: 1em;
}
a {
/*border: 1px solid black;*/
display: inline-block;
line-height: 89%;
overflow: hidden;
}
a:visited, a:active {
text-decoration: none;
color: white;
/*color: #E8E8E8;*/
}
a:link {
text-decoration: none;
color: white;
text-shadow: 3px -3px 0px black, -2px 2px 5px #0056b2;
}
a:hover {
text-shadow: 5px 5px 5px #000;
color: white;
}
Fiddle: http://jsfiddle.net/ADfhj/1/
PS- I've tried the following CSS to no avail:
#textA {
display: none;
}
#word:hover #textA {
display: block;
}
There is no way achieving it using css only. However you can try simple javascript/jquery.
$('.letter').mouseover(function(){
var cont = $(this).attr('id');
$('#content>div').hide();
$('#text_'+cont).fadeIn();
});
Check the Fiddle