Transition duration not working on bootstrap button - css

I am trying to add transition effect on some bootstrap buttons.
The problem is with height and width properties. These change straight away without considering the the transition duration property.
Note that all other properties change within described duration (2s in this case).
HTML
<div class="container">
<div class="row">
<div class="col">
1 of 2
</div>
<div class="col">
2 of 2
</div>
</div>
<div class="row">
<div class="col">
1 of 3
</div>
<div class="col">
2 of 3
</div>
<div class="col">
3 of 3
</div>
</div>
<button type="button" data-toggle="modal" data-target="#infoModal" class="btn btn-outline-warning mt-5 mb-3 3mr-3 ">Learn More</button>
</div>
CSS
.row {
background: #f8f9fa;
margin-top: 20px;
}
.col {
border: solid 1px #6c757d;
padding: 10px;
}
.btn-outline-warning {
border-color: white;
transition: all;
transition-duration: 2s;
}
.btn-outline-warning:hover {
border-color: rgb(255, 136, 0);
background-color: rgba(0,0,0,.5);
transform: rotate(20deg);
width: 300px;
height: 100px;
}
Here is my JSFiddle for more clarification and demonstration.
https://jsfiddle.net/p34mjfr5/11/

If you want to use transition on one of your css property you need to set default value on it first, then change it on hover. specially those propery that need size like px or etc.. width or height following this rule.
.btn-outline-warning {
border-color: white;
transition: 2s all ease;
width: 200px; /* default value */
height: 50px; /* default value */
}
.btn-outline-warning:hover {
border-color: rgb(255, 136, 0);
background-color: rgba(0, 0, 0, .5);
transform: rotate(20deg);
width: 300px;
height: 100px;
}
JSFiddle

Related

css transform rotate flickering/not working

I ran into this issue where I am trying to rotate this div on hover, but when I hover, it tries to hover but then it goes back to the normal position. could you please help?
here is my fiddle: https://jsfiddle.net/Lcb7okfn/
.section-tours{
background-color:pink;
padding:5rem 0 50rem 0;
}
.center-text{
background-color:blue;
padding:30px 0;
}
.col-1-of-3{
width: calc((100%-20px)/3);
}
.card{
background-color: orange;
height:15rem;
transition: all .8s;
perspective: 1000px;
-moz-perspective: 1000px;
}
.card:hover{
transform: rotateY(180deg);
}
Apply the hover to a parent element and also move the perspective declaration to the parent:
.section-tours {
background-color: pink;
padding: 5rem 0 50rem 0;
}
.center-text {
background-color: blue;
padding: 30px 0;
}
h2 {
padding: 0;
margin: 0;
}
.col-1-of-3 {
width: calc((100%-20px)/3);
perspective: 1000px;
}
.card {
background-color: orange;
height: 15rem;
transition: all .8s;
}
.col-1-of-3:hover .card {
transform: rotateY(180deg);
}
<section class="section-tours">
<div class="center-text">
<h2>
Most popular tours
</h2>
</div>
<div class="row">
<div class="col-1-of-3">
<div class="card">
<div class="card class_side">
TEXT
</div>
</div>
</div>
<div class="col-1-of-3">
</div>
<div class="col-1-of-3">
</div>
</div>
</section>

Skewing a background the opposite way round

I've never felt so silly asking a SO question... but here is goes.
I've created a skew which works a charm, see here
.skewed-bg {
background: #E7ADBB;
padding: 200px 0;
transform: skew(0deg, -7deg);
margin-top: -200px;
z-index: 0;
color: white;
}
.skew-lb {
padding-bottom: 50px !important;
}
.content {
transform: skew(0deg, 7deg);
text-align: center;
}
<div class="skewed-bg skew-lb">
<div class="content">
<div class="container">
<div class="row justify-content-center">
<div class="col-12 col-md-10 text-center">
<h1 class="h1 hero-title mb-3">Everything you need to know about...</h1>
</div>
</div>
</div>
</div>
</div>
But when I try to make the skew the opposite way round, everything just turns into mayhem and I have no idea why this is happening - surely it's just reversing the numbers of the skew around? This is my code...
.skewed-bg {
background: #E7ADBB;
padding: 200px 0;
transform: skew(-7deg, 0deg);
margin-top: -200px;
z-index: 0;
color: white;
}
.skew-lb {
padding-bottom: 50px !important;
}
.content {
transform: skew(7deg, 0deg);
text-align: center;
}
<div class="skewed-bg skew-lb">
<div class="content">
<div class="container">
<div class="row justify-content-center">
<div class="col-12 col-md-10 text-center">
<h1 class="h1 hero-title mb-3">Everything you need to know about...</h1>
</div>
</div>
</div>
</div>
</div>
Can somebody put me out of my misery here? PS- I apologise in advance for being a plonker.
The reason it doesn't work is because skew(ax, ay). If you simply reversed the angles, you would be changing x-axis instead of y-axis. So use an inverse angle instead. 7deg becomes -7deg
Read about skew here.
Do it like this:
.skewed-bg {
background: #E7ADBB;
padding: 200px 0;
transform: skew(0deg, 7deg);
margin-top: -200px;
z-index: 0;
color: white;
}
.skew-lb {
padding-bottom: 50px !important;
}
.content {
transform: skew(0deg, -7deg);
text-align: center;
}
<div class="skewed-bg skew-lb">
<div class="content">
<div class="container">
<div class="row justify-content-center">
<div class="col-12 col-md-10 text-center">
<h1 class="h1 hero-title mb-3">Everything you need to know about...</h1>
</div>
</div>
</div>
</div>
</div>
Here is an example of how you can achieve the same result using :before selector. Less nesting.
.container {
text-align: center;
height: 300px;
width:900px;
position: relative;
overflow: hidden;
margin: 0 auto;
}
.container:before {
content: "";
position: absolute;
background: darkOrange;
height:100%;
width: 200%;
transform: rotate(15deg);
top: -35%;
left: -25%;
z-index: -1;
}
h1 {
z-index: 1;
color: white;
width: 100%;
line-height: 120px;
text-align: center;
}
<div class="container">
<h1>Exmaple </h1>
</div>
Using this method, the text will not be skewed
change the -7 into a 7 in the skew
and for the content flip them over so ts like this skew(0deg, -7deg)
.skewed-bg {
background: #E7ADBB;
padding: 200px 0;
transform: skew(0deg, 7deg);
margin-top: -200px;
z-index: 0;
color: white;
}
.skew-lb {
padding-bottom: 50px !important;
}
.content {
transform: skew(0deg, -7deg);
text-align: center;
}
<div class="skewed-bg skew-lb">
<div class="content">
<div class="container">
<div class="row justify-content-center">
<div class="col-12 col-md-10 text-center">
<h1 class="h1 hero-title mb-3">Everything you need to know about...</h1>
</div>
</div>
</div>
</div>
</div>

Footer Navbar Overlaps Content

So I have a website that looks like this:
(I censored it a little, it's super secret)
Now in full screen on PC this looks just fine but watch what happens when I shrink it down to Mobile Size:
I can no longer reach the bottom and see the three buttons. After experimenting it appears that the buttons shrink down to a very small size and then the bottom navbar overlaps.
<div class="categories-container">
<div class="container">
<div class="h1" style="color: #ffffff;text-align: center;">Or Click One of these Core Categories!</div>
<div class="btn-group btn-group-justified" role="group" aria-label="...">
<div class="btn-group" role="group" style="padding-right: 10px">
<button type="button" class="btn btn-success btn-bg" id="category-gameplay-btn"></button>
</div>
<div class="btn-group" role="group" style="padding-right: 10px">
<button type="button" class="btn btn-warning btn-bg" id="category-editor-btn"></button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-danger btn-bg" id="category-engine-btn"></button>
</div>
</div>
</div>
</div>
<div class="footer-container">
<div class="navbar navbar-default navbar-fixed-bottom">
<div class="container" style="text-align: center">
<span>Website made possible with the following tools</span>
<br>
<span>
jQuery | Bootstrap | glyphicons | <a href="https://pages.github.com/">Github Pages</a>
</span>
</div>
</div>
</div>
This should be the code you need. If you require more let me know.
EDIT
CSS Below:
body {
background-color: #0ba7ff;
}
.header-container .jumbotron {
background-color: #0ba7ff;
border-color: #ffffff;
border-style: solid;
color: #ffffff;
text-align: center;
}
#media (max-width: 767px) {
.jumbotron.jumbotronic {
padding-left: 20px;
padding-right: 20px;
}
}
.categories-container .btn.btn-bg {
height: 300px;
font-size: 60px;
white-space: normal;
}
#media (max-width: 767px) {
.categories-container .btn.btn-bg {
height: 150px;
font-size: 30px;
}
}
#media (max-width: 480px) {
.categories-container .btn.btn-bg {
height: 75px;
font-size: 22px;
}
}
#media (max-width: 360px) {
.categories-container .btn.btn-bg {
height: 35px;
font-size: 15px;
}
}
/* Base styles for the entire tooltip */
[data-tooltip]:before,
[data-tooltip]:after,
.tooltip:before,
.tooltip:after {
position: absolute;
visibility: hidden;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0);
opacity: 0;
-webkit-transition:
opacity 0.2s ease-in-out,
visibility 0.2s ease-in-out,
-webkit-transform 0.2s cubic-bezier(0.71, 1.7, 0.77, 1.24);
-moz-transition:
opacity 0.2s ease-in-out,
visibility 0.2s ease-in-out,
-moz-transform 0.2s cubic-bezier(0.71, 1.7, 0.77, 1.24);
transition:
opacity 0.2s ease-in-out,
visibility 0.2s ease-in-out,
transform 0.2s cubic-bezier(0.71, 1.7, 0.77, 1.24);
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
pointer-events: none;
}
/* Show the entire tooltip on hover and focus */
[data-tooltip]:hover:before,
[data-tooltip]:hover:after,
.tooltip:hover:before,
.tooltip:hover:after{
visibility: visible;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
opacity: 1;
}
/* Base styles for the tooltip's content area */
.tooltip:after,
[data-tooltip]:after {
z-index: 1000;
padding: 8px;
width: 160px;
background-color: #000;
background-color: hsla(0, 0%, 20%, 0.9);
color: #fff;
content: attr(data-tooltip);
font-size: 14px;
line-height: 1.2;
}
/* Base styles for the tooltip's directional arrow */
.tooltip:before,
[data-tooltip]:before {
z-index: 1001;
border: 6px solid transparent;
background: transparent;
content: "";
}
/* Horizontally align top/bottom tooltips */
[data-tooltip]:after,
.tooltip:after,
.tooltip-top:after {
margin-left: -80px;
}
[data-tooltip]:hover:before,
[data-tooltip]:hover:after,
[data-tooltip]:focus:before,
[data-tooltip]:focus:after,
.tooltip:hover:before,
.tooltip:hover:after,
.tooltip:focus:before,
.tooltip:focus:after,
.tooltip-top:hover:before,
.tooltip-top:hover:after,
.tooltip-top:focus:before,
.tooltip-top:focus:after {
-webkit-transform: translateY(-12px);
-moz-transform: translateY(-12px);
transform: translateY(-12px);
}
/* Bottom */
.tooltip-bottom:before,
.tooltip-bottom:after {
top: 100%;
bottom: auto;
left: 50%;
}
.tooltip-bottom:before {
margin-top: -12px;
margin-bottom: 0;
border-top-color: transparent;
border-bottom-color: #000;
border-bottom-color: hsla(0, 0%, 20%, 0.9);
}
.tooltip-bottom:hover:before,
.tooltip-bottom:hover:after,
.tooltip-bottom:focus:before,
.tooltip-bottom:focus:after {
-webkit-transform: translateY(12px);
-moz-transform: translateY(12px);
transform: translateY(12px);
}
Loaded after bootstrap.css
It appears you're using bootstrap. I don't know the coding of your css file but if you do happen to set a height for .categories it'd tend to overlap. Try give it a .row class and .col-sm-13 for the buttons to remain inline. Once it reaches the screen of a mobile device it won't overlap. Try. I hope this helps or gives you an idea :)
<div class="categories-container">
<div class="container">
<div class="h1" style="color: #ffffff;text-align: center;">Or Click One of these Core Categories!</div>
<div class="row">
<div class="btn-group btn-group-justified col-sm-12" role="group" aria-label="...">
<div class="btn-group" role="group" style="padding-right: 10px">
<button type="button" class="btn btn-success btn-bg" id="category-gameplay-btn"></button>
</div>
<div class="btn-group" role="group" style="padding-right: 10px">
<button type="button" class="btn btn-warning btn-bg" id="category-editor-btn"></button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-danger btn-bg" id="category-engine-btn"></button>
</div>
</div>
</div> <!-- row-->
</div>
So here is the solution for anyone else looking after a fix for this:
There was none from what I experience, make your own:
This is necessary to add:
body {
height: 100%;
}
Here is the CSS for the div which holds the three buttons in question (so basically the last container in your HTML document before the footer):
.categories-container {
min-height: 100%;
margin-bottom: -30px; /* Negative half the height of the footer to leave space*/
position: relative;
}
Then I made this at the bottom of my index.html page:
<div id="wrap">
<div id="main"></div>
<div id="footer">
jQuery | Bootstrap |
glyphicons | <a href="https://pages.github.com/">Github Pages</a>
</div>
</div>
Here is the footer CSS:
#wrap #footer {
position: relative;
bottom: 0;
width: 100%;
height: 60px;
background: #f8f8f8;
text-align: center;
}
#wrap #footer a {
padding-top: 30px;
}
#wrap #main {
height: 60px;
clear: both;
}
I hope this was useful for some!

CSS : Button is shifing bit downward as compared to label

Using
github link
HTML Code
<div class="col-md-12">
<div class="col-md-2">
Processing
</div>
<div class="col-md-4">
<button class="btn btn-primary">Hello</button>
</div>
</div>
.btn {
position: relative;
padding: 8px 30px;
border: 0;
margin: 10px 1px; cursor: pointer;
border-radius: 2px;
text-transform: uppercase;
text-decoration: none;
color: rgba(255, 255, 255, 0.84);
transition: background-color 0.2s ease, box-shadow 0.28s cubic-bezier(0.4, 0, 0.2, 1); outline: none !important; }
You can clearly notice that button is going down as compared to label.
Any CSS Fix? temporary may be??
A middle vertical-align and a display of inline-block should fix this.
Booply
<div class="col-md-12">
<div class="col-md-2 vcenter">
Processing
</div>
<div class="col-md-4 vcenter">
<button class="btn btn-primary">Hello</button>
</div>
</div>
.vcenter {
display: inline-block;
vertical-align: middle;
float: none;
}

Margin, Border, Padding - Same(ish) code with different outcome. Please take a look

I have two pretty similar code snippets using CSS tricks as my lesson (http://css-tricks.com/video-screencasts/93-css3-slideup-boxes/). I'm using Bootstrap with ruby on rails.
1st:
<div class="row center">
<div class="col-md-3 slide-up-captions">
<a href="#">
<h5>Absolute Me</h5>
<div>Some other text...</div>
</a>
</div>
<div class="col-md-3 slide-up-captions">
<a href="#">
<h5>Absolute Me</h5>
<div>GSome other text...</div>
</a>
</div>
<div class="col-md-3 slide-up-captions">
<a href="#">
<h5>Absolute Me</h5>
<div>Some other text...</div>
</a>
</div>
<div class="col-md-3 slide-up-captions">
<a href="#">
<h5>Absolute Me</h5>
<div>Something else...</div>
</a>
</div>
</div>
and 2nd:
<div class="slide-up-captions row center">
<a href="#" class="col-md-3">
<h5>absolute me</h5>
<div>Some other text...</div>
</a>
<a href="#" class="col-md-3">
<h5>absolute me</h5>
<div>Some other text...</div>
</a>
<a href="#" class="col-md-3">
<h5>absolute me</h5>
<div>Some other text...</div>
</a>
<a href="#" class="col-md-3">
<h5>absolute me</h5>
<div>Some other text...</div>
</a>
</div>
CSS for both:
.slide-up-captions a {
display: block;
background: $lightBlue;
border: 1px solid $grayMediumLight;
height: 65px;
margin: 0 0 20px 0;
overflow: hidden;
}
.slide-up-captions h5 {
height: 65px;
text-align: center;
line-height: 65px;
-webkit-transition: margin-top 0.2s linear;
}
.slide-up-captions a:hover h5 {
margin-top: -65px;
}
.slide-up-captions div {
height: 45px;
padding: 10px;
opacity: 0;
-webkit-transition: all 0.3s linear;
-webkit-transform: rotate(6deg);
}
.slide-up-captions a:hover div {
opacity: 1;
-webkit-transform: rotate(0);
}
These display differently and the 1st allows nth child selection of the in the .slide-up-caption class, whereas the 2nd does not (I know I could use ID).
When I add Margin to the left and right of .slide-up-captions a {}, it causes the 2nd to wrap to a new line, which is not the effect I am going for.
I have used the Developer Tools to inspect and both are very similar.
1st
Row: 970x85 with -15 left and right margin
Col-m-3: 212.5x85 with 15 left and right padding
a: 210.5x63 with 1px border and 20 bottom margin
2nd
Row: 970x85 with -15 left and right margin
a col-m-3: 210.5x63 with 15 left and right padding and 1px border and 20 bottom margin
GOAL: I would like to have the spacing of 1st with the nth child ability of the 2nd. Perhaps there is something going on with the gutter of bootstrap and how it does math? Any help in resolving is much appreciated. I've already searched and trial/errored for hours.
Alright, the best I could come up with to make there be whitespace between the equal columns was to add margin to the inner component, in this case the and the within the
You can also play with the nth child selector to make the 1st and only have right margin, and then the last nth child to make the and only have left margin. This makes the boxes take up the full row.
Hope this works for other people too.
.slide-up-captions a {
display: block;
// background: $lightBlue;
// border: 1px solid $grayMediumLight;
height: 65px;
padding: 0px; //**** added this
margin: 0 0px 20px 0px;
overflow: hidden;
}
.slide-up-captions h5 {
height: 65px;
text-align: center;
line-height: 65px;
margin: 0 10px 0 0px;
background: $lightBlue;
-webkit-transition: margin-top 0.2s linear;
}
.slide-up-captions a:hover h5 {
margin-top: -65px;
}
.slide-up-captions div {
height: 45px;
padding: 10px;
margin: 0 10px;
opacity: 0;
-webkit-transition: all 0.3s linear;
-webkit-transform: rotate(6deg);
}
.slide-up-captions a:hover div {
opacity: 1;
-webkit-transform: rotate(0)
}

Resources