Unable to get a link class to change on hover - html

So I have a link within a button that has a class assignment. The link class dictates color however on hover does not shift as instructed. Can someone help me find a solution to fix?
Here is the HTML...
<div class="row block well" id="section5">
<h1 style="text-align:center">Financing</h1>
<button class = "button1">Apply for a Vehicle Loan</button>
</div>
And here is the CSS...
.button1 {
display: block;
background-color: white;
font-size: 30px;
border: 4px solid #b5cfc1;
border-radius: 10px;
margin: 0 auto;
}
.button1:hover {
background-color: #3d4e3b;
box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 50px 0 rgba(0, 0, 0, 0.19);
}
.apply {
color: #3d4e3b;
}
.apply:hover span{
color: white;
}

Here you are:
.button1 {
display: block;
background-color: white;
font-size: 30px;
border: 4px solid #b5cfc1;
border-radius: 10px;
margin: 0 auto;
}
.button1:hover {
background-color: #3d4e3b;
box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 50px 0 rgba(0, 0, 0, 0.19);
}
.apply {
color: #3d4e3b;
}
.button1:hover .apply {
color: white;
}
<div class="row block well" id="section5">
<h1 style="text-align:center">Financing</h1>
<button class="button1">Apply for a Vehicle Loan
</button>
</div>

.button1 {
display: block;
background-color: white;
font-size: 30px;
border: 4px solid #b5cfc1;
border-radius: 10px;
margin: 0 auto;
color: #3d4e3b;
}
.button1:hover {
background-color: #3d4e3b;
box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 50px 0 rgba(0, 0, 0, 0.19);
color: #b5cfc1;
}
<div class="row block well" id="section5">
<h1 style="text-align:center">Financing</h1>
<button class="button1">Apply for a Vehicle Loan</button>
</div>
Luke your answer worked for the coloring but the link was then broken. After working through it I found a solution that both allows for the link to follow style and still remain functional. See below...
<div class="row block well" id="section5">
<h1 style="text-align:center">Financing</h1>
<button class="button1">Apply for a Vehicle Loan</button>
</div>
.button1 {
display: block;
background-color: white;
font-size: 30px;
border: 4px solid #b5cfc1;
border-radius: 10px;
margin: 0 auto;
color: #3d4e3b;
}
.button1:hover {
background-color: #3d4e3b;
box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 50px 0 rgba(0, 0, 0, 0.19);
color: #b5cfc1;
}
First, I needed to nest the button in the link rather than the other way around. This allows for the entire button to be a link. Next, because the button was now nested in the link I could create style for the inner element (button) rather than trying to stylize the parent and than style the child which was causing a conflict. Endless thanks to everyone that contributed to finding a complete solution, unfortunately some answers have been removed so I cannot attribute individually, but it was all instrumental. Cheers!

Related

all parent elements moving when i hover the cursor on the child element

I have parent div and four child divs. the parent element is a container and child elements are buttons. I set the CSS property of the button to increase its border-width when I hover on it. the actual problem is whenever the button increases its border-width; the entire webpage moving. how can I make the webpage stable?
#theme-options-wrapper {
display: flex;
justify-content: center;
}
.theme-button {
height: 30px;
width: 30px;
border-radius: 50%;
background-color: black;
margin: 5px;
cursor: pointer;
border: 2px solid #000000;
-webkit-box-shadow: -3px 3px 5px -1px rgba(0, 0, 0, 0.69);
-moz-box-shadow: -3px 3px 5px -1px rgba(0, 0, 0, 0.69);
box-shadow: -3px 3px 5px -1px rgba(0, 0, 0, 0.69);
}
.theme-button:hover {
border-width: 5px;
}
#light-mode {
background-color: #ffff;
}
#blue-mode {
background-color: #192734;
}
#green-mode {
background-color: #78866b;
}
#purple-mode {
background-color: #7e4c74;
}
<div id="theme-options-wrapper">
<div data-mode="light" id="light-mode" class="theme-button"></div>
<div data-mode="green" id="green-mode" class="theme-button"></div>
<div data-mode="purple" id="purple-mode" class="theme-button"></div>
<div data-mode="blue" id="blue-mode" class="theme-button"></div>
</div>
here the page URL link
https://nanthu0123.github.io/portfolio/
image of buttons (child elements)
buttons-img
here the source code
https://github.com/nanthu0123/portfolio
hey, add box-sizing: border-box; property to your .theme-button class.
UPDATE:
also if you want make your button larger add transform: scale(1.3); to your pseudo class (.theme-button:hover)
One option is to simply not use the border to draw the border, instead use the box-shadow property, which can take a comma-separated list of box-shadow definitions; below I've added a 2-pixel 'fake border' after the definition of the original box-shadow:
box-shadow: -3px 3px 5px -1px rgba(0, 0, 0, 0.69), 0 0 0 2px #000;
And, within the :hover pseudo-class expanded that 2-pixel size to 5-pixels:
box-shadow: -3px 3px 5px -1px rgba(0, 0, 0, 0.69), 0 0 0 5px #000;
As the box-shadow doesn't take space in the document it won't force elements to reflow (though obviously a repaint is required to show the changed shadow).
#theme-options-wrapper {
display: flex;
justify-content: center;
}
.theme-button {
height: 30px;
width: 30px;
border-radius: 50%;
background-color: black;
margin: 5px;
cursor: pointer;
box-shadow: -3px 3px 5px -1px rgba(0, 0, 0, 0.69), 0 0 0 2px #000;
}
.theme-button:hover {
box-shadow: -3px 3px 5px -1px rgba(0, 0, 0, 0.69), 0 0 0 5px #000;
}
#light-mode {
background-color: #ffff;
}
#blue-mode {
background-color: #192734;
}
#green-mode {
background-color: #78866b;
}
#purple-mode {
background-color: #7e4c74;
}
<div id="theme-options-wrapper">
<div data-mode="light" id="light-mode" class="theme-button"></div>
<div data-mode="green" id="green-mode" class="theme-button"></div>
<div data-mode="purple" id="purple-mode" class="theme-button"></div>
<div data-mode="blue" id="blue-mode" class="theme-button"></div>
</div>
This can also be transitioned/animated – the colour, length or both – if required, with a single line:
transition: box-shadow 0.2s linear;
#theme-options-wrapper {
display: flex;
justify-content: center;
}
.theme-button {
height: 30px;
width: 30px;
border-radius: 50%;
background-color: black;
margin: 5px;
cursor: pointer;
box-shadow: -3px 3px 5px -1px rgba(0, 0, 0, 0.69), 0 0 0 2px #000;
transition: box-shadow 0.2s linear;
}
.theme-button:hover {
box-shadow: -3px 3px 5px -1px rgba(0, 0, 0, 0.69), 0 0 0 5px #000;
}
#light-mode {
background-color: #ffff;
}
#blue-mode {
background-color: #192734;
}
#green-mode {
background-color: #78866b;
}
#purple-mode {
background-color: #7e4c74;
}
<div id="theme-options-wrapper">
<div data-mode="light" id="light-mode" class="theme-button"></div>
<div data-mode="green" id="green-mode" class="theme-button"></div>
<div data-mode="purple" id="purple-mode" class="theme-button"></div>
<div data-mode="blue" id="blue-mode" class="theme-button"></div>
</div>
Reference:
box-shadow.
transition.

How to give shadow in a button like this?

In this button a shadow appearing and it looks like another button border there. I tried to use box-shadow property but I failed.
I used this CSS
a {
padding: 10px 40px;
border-radius: 30px;
font-size: 18px;
color: #fff;
border: 1px solid #fff;
box-shadow: 5px 5px 0px #2CBFBB;
}
Can anyone please help me?
You can achieve this effect with filter: drop-shadow and a transparent background:
body {
background: #76D7C4;
}
button {
text-transform: uppercase;
padding: 10px 20px;
color: white;
cursor: pointer;
background: transparent; /* no background! */
border: 1px solid white;
border-radius: 100px;
filter: drop-shadow(5px 5px 1px rgba(0, 0, 0, 0.25));
}
<button>Learn More</button>
Based on chazsolo's answer. It's possible to get shadow on button without shadow on text using absolutely positioned pseudoelement and CSS property inheritance:
body {
background: #76d7c4;
}
button {
text-transform: uppercase;
padding: 10px 20px;
color: white;
cursor: pointer;
background: transparent; /* no background! */
border: 1px solid white;
border-radius: 100px;
position: relative; /* new */
}
button:after {
content: "";
position: absolute;
/* Making pseudoelement the same size as container */
left: 0;
right: 0;
top: 0;
bottom: 0;
/* Inheriting border properties */
border-radius: inherit;
border: inherit;
/* Applying filter with shadow */
filter: drop-shadow(5px 5px 1px rgba(0, 0, 0, 0.25));
}
<button>Learn More</button>
You can also do it by combining box-shadow: ... and box-shadow: inset .... Just adjust the box-shadow so it fits your needs.
Example
body {
background: #32DBD7;
}
button {
background: transparent;
color: #fff;
border: 3px solid #fff;
border-radius: 35px;
padding: 10px 40px;
font-size: 34px;
box-shadow: 3px 3px 4px rgba(0, 0, 0, .25), inset 3px 3px 4px rgba(0, 0, 0, .25);
-moz-box-shadow: 3px 3px 4px rgba(0, 0, 0, .25), inset 3px 3px 4px rgba(0, 0, 0, .25);
-webkit-box-shadow: 3px 3px 4px rgba(0, 0, 0, .25), inset 3px 3px 4px rgba(0, 0, 0, .25);
}
<button>Learn More</button>
.test { margin-top: 2em; }
a {
padding: 10px 40px;
border-radius: 30px;
font-size: 18px;
color: #fff;
border: 1px solid #fff;
box-shadow: 5px 5px 0 darkgray;
text-decoration: none;
}
body {
background-color: #2CBFBB;
}
<div class="test">
Learn More
</div>

CSS: center elements inside <div> side by side

i've been trying all night to center this elements without having them stacked on each other:
I've tried floating them to the left it works, but, they stick to the left side no matter what i did.
HTML:
<div class="center pages clearfix">
<buuton class="center page-number">1</buuton>
<buuton class="center page-number">2</buuton>
<buuton class="center page-number">3</buuton>
</div>
CSS:
.center {
margin-left: auto;
margin-right: auto;
}
.page-number {
display: block;
float: none;
width: 28px;
height: auto;
border-radius: 3px;
background-color: rgba(0, 0, 0, 0.47);
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.34);
text-shadow: 0 2px 5px rgba(0, 0, 0, .5);
font-weight: 400;
line-height: 1.5;
text-align: center;
color: rgba(255, 255, 255, 0.47);
}
just update "display:block" to "display:inline-block" like the below updated css
updated css
.center {
margin-left: auto;
margin-right: auto;
text-align:center;
}
.page-number {
display: inline-block;
float: none;
width: 28px;
height: auto;
border-radius: 3px;
background-color: rgba(0, 0, 0, 0.47);
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.34);
text-shadow: 0 2px 5px rgba(0, 0, 0, .5);
font-weight: 400;
line-height: 1.5;
text-align: center;
color: rgba(255, 255, 255, 0.47);
}
demo
Try this: https://jsfiddle.net/uo23L4n4/
use inline-block instead of block for the buttons.
use text-align:center
<button class=" page-number">1</button>
.center {
margin-left: auto;
margin-right: auto;
text-align: center;
}
.page-number {
display: inline-block;
float: none;
width: 28px;
height: auto;
border-radius: 3px;
background-color: rgba(0, 0, 0, 0.47);
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.34);
text-shadow: 0 2px 5px rgba(0, 0, 0, .5);
font-weight: 400;
line-height: 1.5;
text-align: center;
color: rgba(255, 255, 255, 0.47);
}
Change your mark up to a list, makes it very easy to do this.
<ul class="center pages clearfix">
<li><buuton class="center page-number">1</buuton></li>
<li><buuton class="center page-number">2</buuton></li>
<li><buuton class="center page-number">3</buuton></li>
</ul>
Use this css
ul{
list-style:none;
}
li{
display:inline-block;
}

Align and Justify Text with HTML

I'm wanting to align the text in my blog posts with the edges of my images. Right now the body of text is slightly skewed to the left. And also, what code do I need to enter so that the text is justified and where exactly do I enter it?
The site is: http://www.studywithstyleblog.com
And below is some of the code:
.post {
margin: 0 0 $(post.margin.bottom) 0;
}
h3.post-title, .comments h4 {
font: $(post.title.font);
margin: 0em 0 0;
}
.post-body {
font-size: 110%;
line-height: 1.4;
position: relative;
width: 700px;
}
.post-body img, .post-body .tr-caption-container, .Profile img, .Image img,
.BlogList .item-thumbnail img {
padding: $(image.border.small.size);
background: $(image.background.color);
border: 1px solid $(image.border.color);
-moz-box-shadow: 1px 1px 5px rgba(0, 0, 0, .1);
-webkit-box-shadow: 1px 1px 5px rgba(0, 0, 0, .1);
box-shadow: 1px 1px 5px rgba(0, 0, 0, .1);
}
.post-body img, .post-body .tr-caption-container {
padding: 3px;
}
.post-body .tr-caption-container {
color: $(image.text.color);
}
.post-body .tr-caption-container img {
padding: 0;
background: transparent;
border: none;
-moz-box-shadow: 0 0 0 rgba(0, 0, 0, .1);
-webkit-box-shadow: 0 0 0 rgba(0, 0, 0, .1);
box-shadow: 0 0 0 rgba(0, 0, 0, .1);
}
.post-header {
line-height: 1.6;
font-size: 90%;
}
.post-footer {
margin: 20px -2px 0;
padding: 5px 10px;
float: none;
width: 700px;
color: $(post.footer.text.color);
background-color: $(post.footer.background.color);
border-bottom: 1px solid $(post.footer.border.color);
line-height: 1.6;
font-size: 90%;
}
Thanks for your help!
The problem is in your code on your page.
You have <div> tags around your paragraphs instead of <p> tags.
The beginning of your faux-paragraphs are:
<div class="separator" style="clear: both; text-align: left;">
If you can change that "text-align" to justify instead of left, you'll be golden.
If you can get away from the inline CSS, you'll be better for it in the long run too.
The following line will justify your text:
text-align: justify;
I was trying to move the text slightly to the right. But it is impossible to implement in your code. You must have to change your code.There is 1 way to do it
1) Change the class of your paragraphs/text divs to "separator2" instead of "separator" and modify your CSS file like below:
.separator2
{
margin-left:20px
}
Adjust the margin-left accordingly. I have just added dummy value.

How do I achieve a page-over-the-background effect with HTML/CSS?

I'm new to web design. I want to make my page look something like the one here: http://www.456bereastreet.com/archive/200501/turning_a_list_into_a_navigation_bar
where there's a rounded rectangle over the grey background that holds all the content. How do I do this?
This is the basic HTML and CSS style that page is currently using. So, they're wrapping all of their content in a <div> and applying that specific style class to the div.
HTML:
<body>
<div class="wrap">
...Content...
</div>
</body>
CSS:
body {
min-width: 0;
}
body {
color: #333333;
font: 100%/1.4 Georgia,serif;
margin: 0 auto;
max-width: 100%;
min-width: 830px;
padding: 0;
width: 62em;
}
<!--wrap class css code-->
.wrap {
-webkit-border-radius: 4px 4px 4px 4px;
-moz-border-radius: 4px 4px 4px 4px;
border-radius: 4px 4px 4px 4px;
-webkit-box-shadow: 0 0 16px rgba(0, 0, 0, 0.1);
-moz-box-shadow: 0 0 16px rgba(0, 0, 0, 0.1);
box-shadow: 0 0 16px rgba(0, 0, 0, 0.1);
background: none repeat scroll 0 0 #FFFFF0;
margin: 16px;
padding: 10px 0 0;
position: relative;
}