Good Afternoon,
I realize this topic has been asked several times and has got several solutions to as I have seen from searching your forums.
But solutions such as,
<input type="button" value="Click Me" **style="float: right;"**>,
Even though do successfully align the button to the right, they overlap my footer as the button is supposed to be right above the footer. This is my code:
.button {
border-radius: 4px;
background-color: #0FA0FF;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 15px;
padding: 10px;
width: 200px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
.containers-fluid {
padding: 20px 50px;
background-color: #000000;
color: white;
}
<button class="button"><span>Proceed to Next Lesson </span>
</button>
<footer class="containers-fluid text-center">
</footer>
Just add style float:right to your button
add this between button and footer
<div class="clearfix"></div>
and css for clearfix
.clearfix{
clear: both;
}
Read more about clearfix
.button {
border-radius: 4px;
background-color: #0FA0FF;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 15px;
padding: 10px;
width: 200px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
float: right;
display: block;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
.containers-fluid {
padding: 20px 50px;
background-color: #000000;
color: white;
}
.clearfix{
clear: both;
}
<button class="button"><span>Proceed to Next Lesson </span>
</button>
<div class="clearfix"></div>
<footer class="containers-fluid text-center">
</footer>
You can use float:right and set the position attribute to relative
Just wrap them both inside a container with display:flex;flex-direction:row; and then apply margin-right:0; to the button.
See the code below
.container{
display:flex;
flex-direction:column;
}
.button {
border-radius: 4px;
background-color: #0FA0FF;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 15px;
padding: 10px;
width: 200px;
transition: all 0.5s;
cursor: pointer;
margin: 5px 0 5px auto;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
.containers-fluid {
padding: 20px 50px;
background-color: #000000;
color: white;
}
<div class="container">
<button class="button"><span>Proceed to Next Lesson </span>
</button>
<footer class="containers-fluid text-center">
</footer>
</div>
Related
Im new to css and html and im trying to make a good looking website for my FiveM RP Server, and im having issues with the buttons
a:visited {
color: white;
text-decoration: none;
}
a:link {
color: white;
text-decoration: none;
}
a:after {
border-bottom: solid 3px #019fb6;
transform: scaleX(0);
transition: transform 250ms ease-in-out;
}
a:hover {
color: green;
border-bottom: 3px solid #004F10;
transform: scaleX'(1);
}
a:active {
color: darkgreen;
}
<header>
<ul>
<h2>Home</h2>
<h2>Rules</h2>
<h2>Discord</h2>
</ul>
</header>
I have displayed the "a" tag as an inline-block so that it doesn't occupy the whole container width.
In your code, you forgot to add content property. And the hover is applied to the ::after selector of the "a" tag not the "a" tag itself. Here is the fix to your code.
a{
display: inline-block;
color: white;
text-decoration: none;
}
a::after {
display: block;
content: '';
border-bottom: solid 3px darkgreen;
transform: scaleX(0);
transition: transform 250ms ease-in-out;
}
a:hover::after{
transform: scaleX(1);
}
a:active{
color: darkgreen;
}
a:visited{
color: white;
text-decoration: none;
}
Check this CodePen from Peter, he did exactly what you want.
Code:
<nav>
<div id="wrapper">
<ul>
<li>item1</li>
<li>item2</li>
<li class="different">item3</li>
<li class="different">item4</li>
</ul>
</div>
</nav>
CSS:
body, html{
width:100%;
height:100%;
background-color: #999999;
}
*{
box-sizing:border-box;
margin:0;
padding:0;
list-style:none;
font-family: Helvetica;
}
nav{
width: 100%;
height: 50px;
position: fixed;
top: 0;
left:0;
background-color: #333333;
}
#wrapper{
width: 100%;
height: 100%;
overflow: hidden;
display: block;
float: left;
}
#wrapper ul{
diplay: block;
width: 50%;
margin: 0 auto;
height: 100%;
text-align: center;
}
#wrapper li{
display: block;
float: left;
text-align: center;
width: 25%;
height: 100%;
transition: all ease-in-out .2s;
}
#wrapper a{
display: block;
float: left;
color: white;
width: 100%;
padding: 0 .5em;
line-height: 50px;
text-decoration: none;
font-weight: bold;
}
li.different{
border:none;
position: relative;
}
li.different:hover{
border: none;
}
li:hover {
border-bottom: 5px solid #FFFFFF;
}
.different::after{
content: '';
position: absolute;
width: 0px;
height: 5px;
left: 50%;
bottom:0;
background-color: white;
transition: all ease-in-out .2s;
}
.different:hover::after{
width: 100%;
left: 0;
}
CodePen
There are total 3 animation.
1st with default top-down animation.
2nd with fade animation
3rd with fade and scale animation.
.main-container{
display: flex;
}
/* First tag */
.testAni {
font-size: 50px;
display: inline-block;
position: relative;
color: darkgreen;
text-decoration: none;
margin-right: 20px;
}
.testAni:after {
content: '';
position: absolute;
border-bottom: 5px solid darkgreen;
width: 100%;
left: 0;
top: 30px;
transition: 0.5s all ease;
}
.testAni:hover:after {
top: 100%;
}
/* Second tag */
.testAni2:after {
content: '';
position: absolute;
border-bottom: 5px solid darkgreen;
width: 100%;
left: 0;
top: 30px;
transition: 0.5s all ease;
opacity: 0;
}
.testAni2:hover:after {
top: 100%;
opacity: 1;
}
/* Third tag */
.testAni3:after {
content: '';
position: absolute;
border-bottom: 5px solid darkgreen;
transform: scale(0.1);
left: 0;
top: 30px;
transition: 0.5s all ease;
opacity: 0;
}
.testAni3:hover:after {
top: 100%;
transform: scale(1);
opacity: 1;
}
<div class="main-container">
<h2><a class="testAni" href="index.html">Home</a></h2>
<h2><a class="testAni testAni2" href="index.html">Home</a></h2>
<h2><a class="testAni testAni2 testAni3" href="index.html">Home</a></h2>
</div>
i started to program recently , and i'm trying to do an client are button and it's not working. Maybe some of you can help me
.areacliente {
width: 100px;
height: 100px;
position: absolute;
right: 15px;
top: 13px;
width: 130px;
margin-top: -10px;
text-align: right;
transition: .3s;
cursor: pointer;
}
.btn {
border: 1.2px solid #8e44ad;
border-radius: 8px;
background: none;
padding: 5px 10px;
font-size: 14px;
margin: 5px;
color: #9b59b6;
list-style: none;
}
.btn li a {
text-decoration: none;
cursor: pointer;
}
<div class="areacliente">
<ul class="btn">
<li>Client Area<i id="lock"class="fas fa-user-lock"></i></li>
</ul>
</div>
Your issue is that your nav is floating on top of your 'Client Area' button so you can click on it. To fix this you need to change the z-index of this button:
.areacliente {
position: absolute;
right: 15px;
top: 13px;
width: 130px;
margin-top: -10px;
text-align : right;
transition: .3s;
cursor: pointer;
z-index: 1; /* Add this */
}
This will bring the button above the nav so you can now click on it.
See working example in this fiddle.
.areacliente {
width: 100px;
height: 100px;
position: absolute;
right: 15px;
top: 13px;
margin-top: -10px;
text-align: right;
transition: .3s;
cursor: pointer;
}
.btn {
border: 1.2px solid #8e44ad;
border-radius: 8px;
background: none;
padding: 5px 10px;
font-size: 14px;
margin: 5px;
color: #9b59b6;
list-style: none;
}
.btn li a {
text-decoration: none;
cursor: pointer;
}
<div class="areacliente">
<ul class="btn">
<li>Client Area<i id="lock"class="fas fa-user-lock"></i></li>
</ul>
</div>
I think left side space problem.so width: 100px; only use remove other one width: 130px
.areacliente {
width: 100px;
height: 100px;
position: absolute;
right: 15px;
top: 13px;
width: 130px;
margin-top: -10px;
text-align: right;
transition: .3s;
cursor: pointer;
}
Hello sorry for my bad english
I looking for answer on internet but it couldn't help me somehow maybe i just cant figure it out. I just need to fit those long word in button.
this is how it looks like now. I posted my code on jsfiddle below
Jsfiddle FIXED
.chkbox {
display: inline-block;
background-color: #FFBB40;
font: bold;
width:150px;
padding: 8px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
border-radius: 4px;
border: none;
color: black;
text-align: center;
padding: 8px;
transition: all 0.5s;
cursor: pointer;
}
.chkbox span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.chkbox span:after {
content: '\2713';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.chkbox:hover span {
padding-right: 25px;
}
.chkbox:hover span:after {
opacity: 1;
right: 0;
}
<button class="chkbox" id="q1a" name="q1" type="button" value="<?php echo $array['0']['2']; ?>"><label for="q1a"><span>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</span></label></button>
Hello its me i found my problem because there was white-space:nowrap in parent div so i cant fit any word in child elements
<div class="w3-display-middle w3-large w3-animate-opacity" id="divclick3" style="white-space:nowrap;">
buttons with spans
</div>
JSFIDDLE FIXED V.2
there is my broken js and i want to achieve all those 4 buttons in 1 line like this next to it
Just add
word-break: break-all;
to the .chkbox class.
.chkbox {
display: inline-block;
background-color: #FFBB40;
font: bold;
width:150px;
padding: 8px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
border-radius: 4px;
border: none;
color: black;
text-align: center;
padding: 8px;
transition: all 0.5s;
cursor: pointer;
word-break: break-all;
}
.chkbox span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.chkbox span:after {
content: '\2713';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.chkbox:hover span {
padding-right: 25px;
}
.chkbox:hover span:after {
opacity: 1;
right: 0;
}
<button class="chkbox" id="q1a" name="q1" type="button" value="<?php echo $array['0']['2']; ?>"><label for="q1a"><span>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</span></label></button>
Should be width:auto; instead of width:150px; inside .chkbox
.chkbox {
display: inline-block;
background-color: #FFBB40;
font: bold;
width:auto;
padding: 8px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
border-radius: 4px;
border: none;
color: black;
text-align: center;
padding: 8px;
transition: all 0.5s;
cursor: pointer;
}
.chkbox span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.chkbox span:after {
content: '\2713';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.chkbox:hover span {
padding-right: 25px;
}
.chkbox:hover span:after {
opacity: 1;
right: 0;
}
<button class="chkbox" id="q1a" name="q1" type="button" value="<?php echo $array['0']['2']; ?>"><label for="q1a"><span>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</span></label></button>
If you want to add more content with 150px width then you can enter valuable text instead of garbage value.
.chkbox {
display: inline-block;
background-color: #FFBB40;
font: bold;
width:150px;
padding: 8px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
border-radius: 4px;
border: none;
color: black;
text-align: center;
padding: 8px;
transition: all 0.5s;
cursor: pointer;
}
.chkbox span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.chkbox span:after {
content: '\2713';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.chkbox:hover span {
padding-right: 25px;
}
.chkbox:hover span:after {
opacity: 1;
right: 0;
}
<button class="chkbox" id="q1a" name="q1" type="button" value="<?php echo $array['0']['2']; ?>"><label for="q1a"><span>this is testing here this is testing here</span></label></button>
The only way I can think of is to use .chkbox span {word-break: break-word} - Read more here
You may be able to improve this with hyphenation as well.
I used this word
.chkbox {
display: inline-block;
background-color: #FFBB40;
font: bold;
width: 150px;
padding: 8px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
border-radius: 4px;
border: none;
color: black;
text-align: center;
padding: 8px;
transition: all 0.5s;
cursor: pointer;
}
.chkbox span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
word-break: break-word;
}
.chkbox span:after {
content: '\2713';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.chkbox:hover span {
padding-right: 25px;
}
.chkbox:hover span:after {
opacity: 1;
right: 0;
}
<button class="chkbox" id="q1a" name="q1" type="button" value="<?php echo $array['0']['2']; ?>"><label for="q1a"><span>Pneumonoultramicroscopicsilicovolcanoconiosis</span></label></button>
I have this awesome button from the Internet, which has a feature to display an arrow facing to the right. Now, I have another button, which goes to a previous page, so common sense would say that the arrow on the button should point to the left.
So I changed all the values which have to do with right-animation to a value for a left-animation, but it doesn't quite work.
I don't understand this quite enough, that's why I'm asking if someone with a better understanding of this can help me out.
.button {
border-radius: 4px;
background-color: #f4511e;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 28px;
padding: 20px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
width: 200px;
}
.button > span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button > span:after {
content: ' »';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover > span {
padding-right: 25px;
}
.button:hover > span:after {
opacity: 1;
right: 0;
}
<button class='button'><span>Back</span>
</button>
<button class='button'><span>Again</span>
</button>
I have this CSS in a common.css which defines a 'standard' button, and in the stylesheets of the page where this HTML is found, it changes some of the CSS (so here the change for my problem must be made) to fit the page's need.
CSS:
li:last-child .button {
width: 200px;
font-size: 22px;
padding: 13px;
}
If anyone could help me out here , I'd be very pleased.
Cheers'
EDIT:
The .button in the common.css has also an width property.
Do this:
.button {
border-radius: 4px;
background-color: #f4511e;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 28px;
padding: 20px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
.button > span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.forward > span:after {
content: ' »';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.back > span:after {
content: '« ';
position: absolute;
opacity: 0;
top: 0;
left: 0px;
transition: 0.5s;
}
.forward:hover > span {
padding-right: 25px;
}
.back:hover > span {
padding-left: 25px;
}
.forward:hover > span:after {
opacity: 1;
right: 0;
}
.back:hover > span:after {
opacity: 1;
left: 0;
}
<html>
<body>
<button class='button back'><span>Back</span>
</button>
<button class='button forward'><span>Again</span>
</button>
</body>
</html>
Check out this fiddle: https://jsfiddle.net/L04y8m9e/
As an alternative, if you really really need to keep the original css, then the solution would be to change the class of the back button from "button" to "backbutton" so that the standard button css does not apply and then copy all the button styles to new "backbutton" styles making the necessary changes.
See this fiddle: https://jsfiddle.net/vg0oLuLh/
New version of html:
<button class='backbutton'><span>Back</span></button>
<button class='button'><span>Again</span></button>
New css to add (the old css remains unchanged):
.backbutton {
border-radius: 4px;
background-color: #f4511e;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 28px;
padding: 20px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
width: 200px;
}
.backbutton > span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.backbutton > span:after {
content: '« ';
position: absolute;
opacity: 0;
top: 0;
left: 0px;
transition: 0.5s;
}
.backbutton:hover > span {
padding-left: 25px;
}
.backbutton:hover > span:after {
opacity: 1;
left: 0;
}
Here is your fixed code:
.button {
border-radius: 4px;
background-color: #f4511e;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 28px;
padding: 20px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
.button > span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.buttonAgain > span:after {
content: ' »';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.buttonBack > span:before {
content: '« ';
position: absolute;
opacity: 0;
top: 0;
left: -70px;
transition: 0.5s;
}
.buttonAgain:hover > span {
padding-right: 25px;
}
.buttonBack:hover > span {
padding-left: 25px;
}
.buttonAgain:hover > span:after {
opacity: 1;
right: 0;
}
.buttonBack:hover > span:before {
opacity: 1;
right: 0;
}
Here is the JSFiddle demo
Hi ive edited your code and got something like this:
.button:first-child > span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button:first-child > span:before {
content: '» ';
position: absolute;
opacity: 0;
top: 0;
left: -20px;
transition: 0.5s;
}
.button:first-child:hover > span {
padding-left: 25px;
}
.button:first-child:hover > span:before {
opacity: 1;
left: 0;
}
here is a working example: https://jsfiddle.net/xde9046k/2/
Use the CSS3 transform property. Play around with the rotate(Xdeg) value.
For more information regarding this property, you can check its details on http://www.w3schools.com/cssref/css3_pr_transform.asp, or https://developer.mozilla.org/en-US/docs/Web/CSS/transform.
Check this..
HTML:
<button class='button'><span>Back</span></button>
<button class='button'><span>Again</span></button>
CSS:
.button {
border-radius: 4px;
background-color: #f4511e;
border: none;
color: #FFFFFF;
text-align: center;
font-size: 28px;
padding: 20px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
.button > span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button > span:before {
content: ' <<';
position: absolute;
opacity: 0;
top: 0;
left:-10px;
transition: 0.5s;
}
.button:hover > span {
padding-left: 25px;
}
.button:hover > span:before {
opacity: 1;
left: -10px;
}
All right? I'm having problems with an effect on CSS. Everything works perfectly until I put the code inside another div, and has a background that is not transparent. Look at the example below:
body {
background: #2ecc71;
padding:0;
margin:0;
}
#bg{
background: #000;
}
.container-button {
padding: 10em;
margin: 0 auto;
width: 1170px;
text-align: center;
display: block;
overflow: hidden;
}
/* GENERAL BUTTON STYLING */
.btn-more-info{
display:block;
overflow: hidden;
text-align: center;
display: inline-block;
float: left;
}
.btn-more-info a,
.btn-more-info a::after {
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
test-ident: -9999px;
text-decoration: none;
}
.btn-more-info a {
background: none;
border: 2px solid #fff;
border-radius: 5px;
color: #fff;
display: block;
font-size: 14px;
font-weight: bold;
padding: 20px 50px;
position: relative;
text-transform: uppercase;
}
.btn-more-info a::before,
.btn-more-info a::after {
background: #fff;
content: '';
position: absolute;
z-index: -1;
}
.btn-more-info a:hover {
color: #2ecc71;
}
/* BUTTON EFFECT */
.btn-effect {
overflow: hidden;
}
.btn-effect::after {
/*background-color: #f00;*/
height: 100%;
left: -35%;
top: 0;
transform: skew(50deg);
transition-duration: 0.6s;
transform-origin: top left;
width: 0;
}
.btn-effect:hover:after {
height: 100%;
width: 135%;
}
.btn-send{
overflow: hidden;
text-align: center;
clear: both;
}
.btn-send a,
.btn-send a::after {
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
test-ident: -9999px;
text-decoration: none;
}
.btn-send a {
background: none;
border: 2px solid #353B4C;
border-radius: 5px;
color: #353B4C;
display: inline-block;
font-size: 14px;
font-weight: bold;
padding: 20px 50px;
position: relative;
text-transform: uppercase;
}
.btn-send a::before,
.btn-send a::after {
background: #353B4C;
content: '';
position: absolute;
z-index: -1;
}
.btn-send a:hover {
color: #FFF;
}
<div id="bg">
<div class="container-button">
<div class="btn-more-info">
Continue lendo
</div>
<div class="btn-send">
Enviar mensagem
</div>
</div>
</div>
You see, if you remove the id="bg" effect functions normally.
Can anyone help me?
Thank U!
The problem is on the z-index of the :before and :after.
Try this:
.btn-more-info a::before,
.btn-more-info a::after {
background: #fff;
content: '';
position: absolute;
z-index: 0;
}
Also increase the z-index on the text inside the button.