I have this code here in CSS:
#submit{
border: 2px solid white;
width: 100px;
background: none;
display: block;
margin: 20px auto;
text-align: center;
border-radius: 30px;
padding: 10px;
outline: none;
color : #fff;
transition: background-color 0.25s;
}
#submit:hover{
background: #bbb;
}
And the problem is that when i try it on my page the transition effects applies to the first background :none that i put, so when you enter the page it seems to change from the original background to none in 0,25s as the transition especifies. If i don´t misunderstand transitions this shouldn´t be happening, what is the problem? In case i´m wrong, how do you make that the transition effects apply after the the background changes in the beginning. Thank you!
Added some HTML to make this readable. Run the code and notice the changes. As you have written in your code, you have set the transition to be on hover, so it only applies whenever you hover your mouse over the container with the submit id.
#submit{
border: 2px solid white;
width: 100vh;
height: 80vh;
background-color: red;
display: block;
margin: 20px auto;
text-align: center;
border-radius: 30px;
padding: 10px;
outline: none;
color : #fff;
transition: 0.25s;
}
#submit:hover{
background: #bbb;
color: black;
}
<div id="submit">
<h1>Content</h1>
</div>
Related
This question already exists:
How to change one element style when another is hovered [closed]
Closed 8 months ago.
Sorry for making things unclear last time, it really was code dump because I didn't know how to explain what was happening. Good news, I fixed it now. However now I a problem with CSS. I am trying to change background colour of a table row () when hovered over a button (my code doesn't work). The css is provided below. The problem is at the buttom of the CSS (the two hover styles): Please tell me what I am doing wrong, I searched for answers for so long however I have not come up with a proper solution.
body{
margin: 0px;
font-family: Helvetica;
}
header{
background-color: #e7e7e7;
height: 100px;
padding-top: 25px;
text-align: center;
font-size: 50px;
}
table{
background-color: white;
border-collapse: collapse;
font-size: 20px;
margin-left: auto;
margin-right: auto;
}
#myTable{
margin-top: 50px;
}
th,td{
padding: 20px;
text-align: center;
border:1px solid black;
width: 200px;
height: auto;
}
.nthChild{
background-color: #e7e7e7;
}
#nlRow th{
border-top: 0px;
}
input{
font-size: 20px;
width: 100%;
padding: 5px 0px;
border-radius: 4px;
}
#numeracyCredits, #literacyCredits{
width: 30%;
}
.button{
font-size: 20px;
padding: 5px 20px;
width: 15%;
border-radius: 4px;
background-color: white;
color: black;
border: 2px solid black;
transition-duration: 0.3s;
}
.button:hover{
background-color: #c4c2c2;
transition-duration: 0.3s;
}
.button:hover + .nthChild{
background-color: white;
}
the .nthChild of what? you should put the parent or whatever from that .nthChild. Or else if you give it a class or an id use that in stead of .nthChild then it should work.
i'm trying to reproduce this https://gyazo.com/848fa4e24ecb33f220a465cdcf571698
only using css.
I got the "arrow" with the border properties and then rotate to the side i want with these css rules and the html:
border-right: 2px solid black;
border-bottom: 2px solid black;
padding: 5px;
transform: rotate(-45deg);
But with i can't find a way to have that element with a background like the image on the link :/
Any hints? Thanks in advance.
Use border-radius:50% for the circle and for the angle use pseudo-class ::before or ::after to display it as content.
Demo
.right-arrow {
display: block;
text-decoration: none;
background: #8AD82F;
border-radius: 50%;
width: 45px;
height: 45px;
}
.right-arrow::after {
content: '\a0\a0\276f';
font-size: 32px;
font-weight: 900;
color: #fff;
}
I'm trying to make a gradual background colour change from normal to a hover colour, but, unfortunately, everything I've read and tried didn't work. This is the code I have:
.button-submit {
color: #ffffff;
cursor: pointer;
display: inline-block;
line-height: 35px;
background: #5ea12b;
padding: 0px 20px;
vertical-align: middle;
font-size: 18px;
min-width: 80px;
min-height: 35px;
font-family: Light;
border: 1px solid transparent;
margin: 5px;
}
.button-submit:hover {
background: #5ea12b;
color: #FFFFFF;
}
Use transition property:
EG:
.button-submit {
background: #5ea12b;
transition: background 0.5s ease-in-out;
}
And on hover, change the background color to little darker tone.
.button-submit:hover {
background: #000;
}
CHECK THE DEMO
I can't get the text inside to sit vertically centered in the box. Right now, its sitting a bit too low.
https://jsfiddle.net/bye5vqpg/
.box {
position:relative;
vertical-align: middle;
color: #0b7;
display: inline-block;
height: 15px;
line-height: 20px;
text-align: center;
transition: 0.5s;
padding: 5px;
cursor: pointer;
border: 1px solid #0b7;
-webkit-transition:0.5s;
}
If it's single row texts you should try line-height with fix height of a div
.box {
position:relative;
color: #0b7;
display: inline-block;
height: 40px; // changed
line-height: 40px; // changed
text-align: center;
transition: 0.5s;
padding: 5px; //removed
cursor: pointer;
border: 1px solid #0b7;
-webkit-transition:0.5s;
}
fiddle
EDIT:
If you still want to add padding to left and right then add
padding: 0 5px;
Change line-height to be 15px. This will work for single line.
I think you should change the "height" to auto and remove the "line-height" or change the "height" to equal with "line-height"
Use display:inline to the box.
.box {
position:relative;
vertical-align: middle;
color: #0b7;
display: inline;
height: 15px;
line-height: 20px;
text-align: center;
transition: 0.5s;
padding: 5px;
cursor: pointer;
border: 1px solid #0b7;
-webkit-transition:0.5s;
}
https://jsfiddle.net/r5jt8uu0/
The squarespace template that I am using will not let me insert the code below. I got a response back that I need to split out the commands manually.
I am getting an error back with the background: I had tried a few times to accomplish this but couldn't quite get it accurate.
.mobile-nav .show-nav {
background: url("http://www.jobspark.ca/item/517adb63e4b06ea9dd79ace8?format=original") no-repeat scroll center center / 30% auto #000000;
border-bottom: 1px solid #000000;
color: #FFFFFF;
cursor: pointer;
display: block;
max-height: 50px;
padding: 1em 40px 50px;
}
Its likely the CSS 3 background shorthand thats causing the problem, support isn't consistent across all platforms and browsers - you should split the shorthand up like so:
.mobile-nav .show-nav {
background-image: url('http://www.jobspark.ca/item/517adb63e4b06ea9dd79ace8?format=original');
background-position: center center;
background-size: 30% auto;
background-color: black;
/* omitted default values */
border-bottom: 1px solid #000000;
color: #FFFFFF;
cursor: pointer;
display: block;
max-height: 50px;
padding: 1em 40px 50px;
}