I have created this pen for an opacity slider that I want to use for client testimonials. I based the CSS of the testimonials off another pen which I could link here if someone would like it. I am very new to coding and am an extreme beginner so pardon my silly mistakes. :P Does anyone have any advice on how to improve this design and how to make it more versatile for once I add more testimonials (maybe 6-8). I am sort of confused by the animation properties and how they are working, i.e the delay and the animation duration. I just kept playing with the numbers until it worked. I plan to have this "slider" in the footer of my site. One thing that bugs me is that it is not centered. How could I center the slider? Also what should I do about the height of the "slider"? The way I am currently doing it doesn't really make sense. Kind of like a lot of that code.
Thanks so so much for any advice given, I strongly appreciate it. :)
Here is the link to my Codepen: [link] (http://codepen.io/ericshio/pen/grzboq)
HTML:
<div class="test-slider">
<div class="test-slide">
<figure class="test">
<img class="img-circle img-border" src="http://www.themainconcept.com/wp-content/uploads/2016/04/eric.png" width="40%"/>
<h2>Eric S.</h2>
<h4>Some Guy</h4>
<blockquote>Insert cheesy quote here! Lorem ipsum dolor sit amet, at lorem graecis ius, qui at veri vocent.</blockquote>
</figure>
</div>
<div class="test-slide">
<figure class="test">
<img class="img-circle img-border" src="http://i1.wp.com/www.visualelegance.ca/wp-content/uploads/2016/07/danielliasquare.png?zoom=2&w=1020" />
<h2>Daniel & Lia</h2>
<h4>Couple</h4>
<blockquote>Words go here from what people have to say.</blockquote>
</div>
</div>
CSS:
.test-slider {
width: 25em;
height: 25em;
margin: auto;
overflow: hidden;
position: relative;
}
.test-slide {
position: absolute;
animation: 30s slider infinite;
-webkit-animation: 30s test-slider infinite;
opacity: 0;
}
#keyframes test-slider {
10% {
opacity: 1;
}
50% {
opacity: 0;
}
}
div.test-slide:nth-child(0) {
animation-delay: 0s;
-webkit-animation-delay: 0s;
}
div.test-slide:nth-child(1) {
animation-delay: 15s;
-webkit-animation-delay: 15s;
}
figure.test {
font-family: lato !important;
position: relative;
float: left;
overflow: hidden;
margin: 10% 1%;
min-width: 15em;
max-width: 20em;
width: 100%;
color: #000000;
text-align: center;
font-size: 1em;
background-color: #2d2d2d;
padding: 8% 8% 8% 8%;
background-image: linear-gradient(-25deg, rgba(0, 0, 0, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
-webkit-box-sizing: border-box;
box-sizing: border-box;
border-radius: 0.3em 0.3em 0.3em 0.3em;
}
figure.test img {
width: 50%;
margin-top: 0;
margin-bottom: 2%;
}
figure.test h2, figure.test h4 {
font-family: lato;
text-transform: none;
margin: 0;
}
figure.test h2 {
font-weight: bold;
color: white;
}
figure.test h4 {
font-weight: normal;
color: #a6a6a6;
}
figure.test blockquote {
margin-top: 5%;
margin-bottom: 0;
padding: 8%;
opacity: 1;
font-style: italic;
font-size: 1em;
background-color: white;
border-radius: 0.3em 0.3em 0.3em 0.3em;
box-shadow: inset -0.1em -0.1em 0.2em rgba(0, 0, 0, 0.3);
text-align: left;
position: relative;
}
.img-border {
border: 0.5em solid tan;
border-radius: 50%;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
-ms-border-radius: 50%;
-o-border-radius: 50%;
box-shadow: 0.4em 0.4em 2em rgba(0, 0, 0, 0.4);
}
.img-circle {
margin: auto;
display: block;
position: relative;
overflow: hidden;
border-radius: 50%;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
-ms-border-radius: 50%;
-o-border-radius: 50%;
}
blockquote, blockquote:before, blockquote:after, blockquote::before, blockquote::after {
margin: auto;
border: none;
position: initial;
content: " ";
quotes: "\201C""\201D""\2018""\2019";
}
blockquote {
}
blockquote:before {
content: open-quote;
}
blockquote::before, blockquote::after {
display: inline;
}
blockquote:after {
content: close-quote;
}
JS:
NONE >:)
What's more important than just to give you the solution is to help you actually see that your element in fact is centered.
I like using red when I debug CSS code, so try putting:
.test-slider {
border: 1px solid red;
}
Now, you probably see for yourself that .test-slider is indeed centered, but its child,.test-slide, is anchored on the top left corner of its parent and since the parent is larger in width, it therefore seems to be off.
To fix that, just set:
.test-slider {
width: 20.4em; /* Instead of 25em */
}
Since .test-slider is invisible and just serves to wrap .test-slide, you don't really care about its width, so this solution is fine.
Another way to do it is by setting:
.test-slide {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
Since you use position: absolute on .test-slide instead of position: relative, you will not face any problems. If later you want to change it to position: relative, you can just set:
.test-slide {
display: inline-block;
margin: 0 auto;
}
Or you could even better set:
.test-slider { /* The parent */
text-align: center;
}
Check out the following fiddles for a more visual representation:
With the first solution → here.
With the second solution → here.
Snippet:
.test-slider {
width: 20.4em;
height: 30em;
overflow: hidden;
position: relative;
margin: 0 auto;
}
.test-slide {
position: absolute;
animation: 30s slider infinite;
-webkit-animation: 30s test-slider infinite;
opacity: 0;
}
#keyframes test-slider {
10% {
opacity: 1;
}
50% {
opacity: 0;
}
}
div.test-slide:nth-child(0) {
animation-delay: 0s;
-webkit-animation-delay: 0s;
}
div.test-slide:nth-child(1) {
animation-delay: 15s;
-webkit-animation-delay: 15s;
}
figure.test {
font-family: lato !important;
position: relative;
float: left;
overflow: hidden;
margin: 10% 1%;
min-width: 15em;
max-width: 20em;
width: 100%;
color: #000000;
text-align: center;
font-size: 1em;
background-color: #2d2d2d;
padding: 8% 8% 8% 8%;
background-image: linear-gradient(-25deg, rgba(0, 0, 0, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
-webkit-box-sizing: border-box;
box-sizing: border-box;
border-radius: 0.3em 0.3em 0.3em 0.3em;
}
figure.test img {
width: 50%;
margin-top: 0;
margin-bottom: 2%;
}
figure.test h2, figure.test h4 {
font-family: lato;
text-transform: none;
margin: 0;
}
figure.test h2 {
font-weight: bold;
color: white;
}
figure.test h4 {
font-weight: normal;
color: #a6a6a6;
}
figure.test blockquote {
margin-top: 5%;
margin-bottom: 0;
padding: 8%;
opacity: 1;
font-style: italic;
font-size: 1em;
background-color: white;
border-radius: 0.3em 0.3em 0.3em 0.3em;
box-shadow: inset -0.1em -0.1em 0.2em rgba(0, 0, 0, 0.3);
text-align: left;
position: relative;
}
.img-border {
border: 0.5em solid tan;
border-radius: 50%;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
-ms-border-radius: 50%;
-o-border-radius: 50%;
box-shadow: 0.4em 0.4em 2em rgba(0, 0, 0, 0.4);
}
.img-circle {
margin: auto;
display: block;
position: relative;
overflow: hidden;
border-radius: 50%;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
-ms-border-radius: 50%;
-o-border-radius: 50%;
}
blockquote, blockquote:before, blockquote:after, blockquote::before, blockquote::after {
margin: auto;
border: none;
position: initial;
content: " ";
quotes: "\201C""\201D""\2018""\2019";
}
blockquote:before {
content: open-quote;
}
blockquote::before, blockquote::after {
display: inline;
}
blockquote:after {
content: close-quote;
}
<div class="test-slider">
<div class="test-slide">
<figure class="test">
<img class="img-circle img-border" src="http://www.themainconcept.com/wp-content/uploads/2016/04/eric.png" width="40%" />
<h2>Eric S.</h2>
<h4>Some Guy</h4>
<blockquote>Insert cheesy quote here! Lorem ipsum dolor sit amet, at lorem graecis ius, qui at veri vocent.</blockquote>
</figure>
</div>
<div class="test-slide">
<figure class="test">
<img class="img-circle img-border" src="http://i1.wp.com/www.visualelegance.ca/wp-content/uploads/2016/07/danielliasquare.png?zoom=2&w=1020" />
<h2>Daniel & Lia</h2>
<h4>Couple</h4>
<blockquote>Words go here from what people have to say.</blockquote>
</figure>
</div>
</div>
Related
I have boxes with some content but not all text is displayed. On click I toggle all the text but the problem is I don't want the bottom element to move, instead I want the toggled div to be on top of the bottom element. Would anyone help with ideas how to do this? Thank you.
Ps. Also, for some reason the transition/animation doesn't work.
Here is a link to codepen: https://codepen.io/christmastrex/pen/gOwGvap and here is my code:
<div class="card">
<div class="card__header js-toggle">
<p class="card__title">“It’s not about weight it’s about how<br> your body changes”</p>
</div>
<div class="card__toggle">
<p>Doing resistance training and cardio combined and I have not lost one single ounce on the scale….I was feeling horribly frustrated being it has been a month so I decided to do a progress sequence and wth look at me now!! It’s not about weight, it’s about how your body changes when you eat right and exercise! Yay!!”</p>
</div>
</div>
<div class="card">
<div class="card__header js-toggle">
<p class="card__title">“It’s not about weight it’s about how<br> your body changes”</p>
</div>
<div class="card__toggle">
<p>Doing resistance training and cardio combined and I have not lost one single ounce on the scale….I was feeling horribly frustrated being it has been a month so I decided to do a progress sequence and wth look at me now!! It’s not about weight, it’s about how your body changes when you eat right and exercise! Yay!!”</p>
</div>
</div>
------------------------------------------------------------
.card {
background-color: #fff;
max-width: 490px;
padding: 20px;
margin-bottom: 30px;
border-radius: 5px;
position: relative;
box-sizing: border-box;
box-shadow: 0 3px 30px 0 rgba(74,74,74,.3);
&__toggle {
overflow: hidden;
max-height: 55px;
p {
font-size: 16px;
margin-bottom: 10px;
}
}
&__title {
font-weight: 900;
margin-bottom: 5px;
}
&__header {
position: relative;
cursor: pointer;
&::after{
content: "\f078";
font-family: "Font Awesome 5 Pro";
font-weight: 400;
display: inline-block;
background-color: #d54f80;
border: 2px solid #d54f80;
color: #fff;
width: 30px;
height: 30px;
border-radius: 15px;
font-size: 14px;
text-align: center;
line-height: 2;
position: absolute;
top: 0;
right: 0;
transition: all .3s ease-in-out;
}
}
&.active {
.card__toggle {
max-height: 700px;
transition: all .3s ease-in-out;
}
.card__header {
&::after {
background-color: #fff;
color: red;
transform: rotate(180deg);
}
}
}
}
-----------------------------------------------------
$(document).ready(function() {
$(".js-toggle").on("click", function () {
$(".card__header.active").not($(this)).removeClass("active").next(".js-card-toggle").slideUp("slow");
$(this).toggleClass("active").next(".js-card-toggle").slideToggle("slow");
$(this).closest(".card").toggleClass("active").siblings().removeClass("active");
});
});```
I think you are trying to achieve this, copy it and see if it works.
HTML:
<div class="card">
<div class="card__header js-toggle">
<p class="card__title">
“It’s not about weight it’s about how<br />
your body changes”
</p>
</div>
<div class="card__toggle">
<p>
Doing resistance training and cardio combined and I have not lost one
single ounce on the scale….I was feeling horribly frustrated being it has
been a month so I decided to do a progress sequence and wth look at me
now!! It’s not about weight, it’s about how your body changes when you eat
right and exercise! Yay!!”
</p>
</div>
</div>
<div class="card">
<div class="card__header js-toggle">
<p class="card__title">
“It’s not about weight it’s about how<br />
your body changes”
</p>
</div>
<div class="card__toggle">
Doing resistance training and cardio combined and I have not lost one single
ounce on the scale….I was feeling horribly frustrated being it has been a
month so I decided to do a progress sequence and wth look at me now!! It’s
not about weight, it’s about how your body changes when you eat right and
exercise! Yay!!”
</div>
</div>
SCSS:
.
card {
max-height: 125px;
overflow: hidden;
background-color: #fff;
max-width: 490px;
padding: 20px;
margin-bottom: 30px;
border-radius: 5px;
position: relative;
height: 150px;
box-sizing: border-box;
box-shadow: 0 3px 30px 0 rgba(74, 74, 74, 0.3);
transition: 0.4s ease;
&.active {
max-height: 210px;
}
&__toggle {
background-color: white;
p {
font-size: 16px;
margin-bottom: 10px;
}
}
&__title {
font-weight: 900;
margin-bottom: 5px;
}
&__header {
position: relative;
cursor: pointer;
&::after {
content: "\f078";
font-family: "Font Awesome 5 Pro";
font-weight: 400;
display: inline-block;
background-color: #d54f80;
border: 2px solid #d54f80;
color: #fff;
width: 30px;
height: 30px;
border-radius: 15px;
font-size: 14px;
text-align: center;
line-height: 2;
position: absolute;
top: 0;
right: 0;
transition: all 0.3s ease-in-out;
}
}
&.active {
.card__toggle {
transition: all 0.3s ease-in-out;
width: 100%;
z-index: 1;
background-color: white;
}
.card__header {
&::after {
background-color: #fff;
color: red;
transform: rotate(180deg);
}
}
}
}
jQuery:
$(".js-toggle").click(function () {
console.log($(this).parents(".card"));
$(this).parents(".card").toggleClass("active");
});
I managed to do find a solution after all.. I made changes to the css only
background-color: #fff;
max-width: 490px;
padding: 20px;
margin: 0 auto 70px auto;
border-radius: 5px;
position: relative;
box-sizing: border-box;
box-shadow: 0 3px 30px 0 rgba(74, 74, 74, 0.3);
&::after {
content: "";
position: absolute;
height: 20px;
background-color: #fff;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
bottom: -40px;
left: 0;
z-index: 10;
width: 100%;
box-shadow: 0 10px 20px -7px rgba(74, 74, 74, 0.3);
transition: all 0.3s ease-in-out;
transition-delay: 0.5s;
}
&__toggle {
overflow: hidden;
max-height: 45px;
position: absolute;
z-index: 1;
background-color: #fff;
margin-left: -20px;
padding-left: 20px;
padding-right: 20px;
border-radius: 5px;
box-shadow: 0 10px 15px -12px rgba(74, 74, 74, 0.3);
transition: all 1s ease-in-out;
p {
font-size: 16px;
margin-bottom: 20px;
line-height: 1.3;
}
&-s {
max-height: 18px;
}
}
&--s {
max-width: 350px;
}
&__img {
border: 5px solid #d54f80;
border-radius: 5px;
padding: 5px 5px 1px 5px;
margin-bottom: 20px;
}
&__title {
font-weight: 900;
margin-bottom: 5px;
}
&__header {
position: relative;
cursor: pointer;
&::after {
content: "\f078";
font-family: "Font Awesome 5 Pro";
font-weight: 400;
display: inline-block;
background-color: #d54f80;
border: 2px solid #d54f80;
color: #fff;
width: 30px;
height: 30px;
border-radius: 15px;
font-size: 14px;
text-align: center;
line-height: 2;
position: absolute;
top: 0;
right: 0;
transition: all 0.3s ease-in-out;
}
}
&.active {
&.card::after {
background-color: transparent;
transition: all 0s ease-in-out;
}
.card__toggle {
max-height: 700px;
}
.card__header {
&::after {
background-color: #fff;
color: pink;
transform: rotate(180deg);
}
}
}
}
I have made a button which has a small tab that upon hovering over it expands to the side. It is there because I want the button to be draggable. So once the tab expands, you can grab it and drag the button around. Don't mind the broken icons, they are supposed to be there from font awesome pack.
However I wanted to inform user, that the small tab can be grabbed, so I made a little jiggle effect on idle that plays two times indicating, that the tab can expand. And once user hovers over it, it fully expands. However when user unhovers the tab, the animation starts again. I need the animation to start only when the page loads and occur exactly 2 times and never again. Why does the aniamtion start after the transition that is there on hover and what can I do to disallow it animating again? Is it possible without JS?
Here is my code
.insite-draggable {
z-index: 10;
position: fixed;
left: 45px;
bottom: 12px;
}
.insite-handle {
position: absolute;
left: -14px;
bottom: 13px;
transition: left 0.3s cubic-bezier(0.32, 1.85, 0.43, 0.43);
animation: bounce 2s;
animation-iteration-count: 2;
animation-delay: 2s;
}
.insite-handle:before {
content: "\f100";
font-family: "Font Awesome 5 Free";
font-style: normal;
font-size: 16px;
line-height: 16px;
display: inline-block;
background-color: #1ea2b1;
cursor: move;
color: #ffffff;
height: 16px;
width: 26px;
padding: 3px 3px 3px 4px;
border-radius: 7px 0px 0px 7px;
border: 1px solid #1a8e9b;
transition: padding-left 0.3s cubic-bezier(0.32, 1.85, 0.43, 0.43);
}
.insite-handle:hover {
left: -27px;
animation: step-end;
&:before {
content: "\f0b2";
padding-left: 5px;
}
}
#keyframes bounce {
0% { left: -14px; }
10% { left: -20px; }
20% { left: -14px; }
30% { left: -20px; }
40% { left: -14px; }
100% {left: -14px; }
}
.insite-btn {
display: block;
position: relative;
top: auto;
left: auto;
bottom: auto;
right: auto;
font-family: 'BrixSansBold';
font-style: italic;
font-size: 0.875rem;
line-height: 1rem;
-ms-border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
color: #b00402;
border: none;
margin: 10px 10px 10px auto;
padding: 7px 10px 7px 34px;
text-decoration: none;
text-transform: none;
box-shadow: #333333 1px 1px 10px;
background-color: #e3e000;
}
<span class="insite-draggable">
<i class="insite-handle"></i>
<a class="insite-btn" href="#">Turn on</a>
</span>
I used CSS Variables with fallback.
var(--use-this-variable-if-exist, use this fallback if no variable);
Initially there is no --left value, so it uses fallbacks. When hover, set --left value as -27px. Thus, the keyframes are also updated.
.insite-draggable {
z-index: 10;
position: fixed;
left: 45px;
bottom: 12px;
}
.insite-handle {
position: absolute;
left: -14px;
bottom: 13px;
transition: left 0.3s cubic-bezier(0.32, 1.85, 0.43, 0.43);
animation: bounce 2s;
animation-iteration-count: 2;
animation-delay: 2s;
}
.insite-handle:before {
content: "\f100";
font-family: "Font Awesome 5 Free";
font-style: normal;
font-size: 16px;
line-height: 16px;
display: inline-block;
background-color: #1ea2b1;
cursor: move;
color: #ffffff;
height: 16px;
width: 26px;
padding: 3px 3px 3px 4px;
border-radius: 7px 0px 0px 7px;
border: 1px solid #1a8e9b;
transition: padding-left 0.3s cubic-bezier(0.32, 1.85, 0.43, 0.43);
}
.insite-handle:hover {
left: -27px;
--left: -27px;
&:before {
content: "\f0b2";
padding-left: 5px;
}
}
#keyframes bounce {
0% {
left: var(--left, -14px);
}
10% {
left: var(--left, -20px);
}
20% {
left: var(--left, -14px);
}
30% {
left: var(--left, -20px);
}
40% {
left: var(--left, -14px);
}
100% {
left: var(--left, -14px);
}
}
.insite-btn {
display: block;
position: relative;
top: auto;
left: auto;
bottom: auto;
right: auto;
font-family: 'BrixSansBold';
font-style: italic;
font-size: 0.875rem;
line-height: 1rem;
-ms-border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
color: #b00402;
border: none;
margin: 10px 10px 10px auto;
padding: 7px 10px 7px 34px;
text-decoration: none;
text-transform: none;
box-shadow: #333333 1px 1px 10px;
background-color: #e3e000;
}
<span class="insite-draggable">
<i class="insite-handle"></i>
<a class="insite-btn" href="#">Turn on</a>
</span>
Below is code to a hamburger menu which I got from a Github Gist. What I want to know is why is the last bar's height not changing and how can I add rounded corners on the bars? Oh, and how can I change the height between the bars? If anyone else has CSS to a single div hamburger menu with those features, let me know.
.hamburger {
display: block;
position: absolute;
top: .5em;
right: .5em;
height: 2.5em;
width: 2.5em;
border: .8em solid rgba(0,133,255,1);
box-shadow: 0 0 0 .1em rgba(255,255,255,0),
inset 0 .3em 0 0 rgba(255,255,255,1),
inset 0 1em 0 0 rgba(0,133,255,1),
inset 0 1.3em 0 0 rgba(255,255,255,1),
inset 0 2em 0 0 rgba(0,133,250,1),
inset 0 2.5em 0 0 rgba(255,255,255,1);
}
<div class="hamburger"></div>
Here's one for you. You can adjust the roundness, thickness and color as you wish.
.menu {
position: relative;
display: inline-block;
width: 30px;
height: 5px;
top: 0px;
border-radius: 5px;
background: #000;
margin: 0;
}
.menu::before {
content: "";
position: absolute;
top: 10px;
left: 0px;
width: 30px;
height: 5px;
border-radius: 5px;
background: #000;
}
.menu::after {
content: "";
position: absolute;
top: 20px;
left: 0px;
width: 30px;
height: 5px;
border-radius: 5px;
background: #000;
}
<div class="menu"></div>
I had this one originally animate to a cross. Without animation you can reduce the code.
Creating the lines with box-shadow will prevent you from rounding them.
You may use pseudo-elements instead
.hamburger-menu
{
width:30px;
height:5px;
background-color:#111;
border-radius:5px;
position:relative;
}
.hamburger-menu:after, .hamburger-menu:before
{
content: '';
width: 100%;
height:5px;
background-color:#111;
position:absolute;
border-radius:5px;
}
.hamburger-menu:after
{
top:10px;
}
.hamburger-menu:before
{
top:20px;
}
<div class="hamburger-menu"> </div>
With the box-shadow method there's no way to add a border-radius, however this is other approach (Close hover is a plus ;) )
*,
*:after,
*:before {
margin: 0;
padding: 0;
-webkit-box-sizing: inherit;
box-sizing: inherit;
-webkit-transition: all ease 0.3s;
transition: all ease 0.3s;
}
*:hover,
*:after:hover,
*:before:hover {
-webkit-transition: all ease 0.3s;
transition: all ease 0.3s;
}
.right {
background: #000;
padding: 10px;
}
.right .bar {
width: 40px;
margin: auto;
border-radius: 2px;
height: 8px;
margin-top: 5px;
display: block;
background: #fff;
}
.right:hover .container-bar {
-webkit-transform: translateX(10px);
transform: translateX(10px);
}
.right:hover .bar {
width: 40px;
margin: auto;
height: 8px;
margin-top: 5px;
display: block;
background: #fff;
}
.right:hover .bar:nth-child(1) {
-webkit-transform-origin: left top;
transform-origin: left top;
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.right:hover .bar:nth-child(2) {
opacity: 0;
}
.right:hover .bar:nth-child(3) {
-webkit-transform-origin: left bottom;
transform-origin: left bottom;
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
}
<div class="right triggerMenu">
<div class="container-bar">
<a href="javascript:void(0);">
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</a>
</div>
</div>
I came across this pen which is a really cool floating share button. Here's the link:
http://codepen.io/koenigsegg1/pen/pjeJvb
HTML
#import url(https://fonts.googleapis.com/css?family=Roboto:100,200,300,400,500);
body {
background: #00BCD4;
min-height: 100vh;
overflow: hidden;
font-family: Roboto;
color: #fff;
}
h1 {
font: 200 60px Roboto;
text-align: center;
}
p.credits {
text-align: center;
margin-top: 100px;
}
.credits img {
border-radius: 50%;
width: 100px;
}
.container {
bottom: 0;
position: fixed;
margin: 1em;
right: 0px;
}
.buttons {
box-shadow: 0px 5px 11px -2px rgba(0, 0, 0, 0.18), 0px 4px 12px -7px rgba(0, 0, 0, 0.15);
border-radius: 50%;
display: block;
width: 56px;
height: 56px;
margin: 20px auto 0;
position: relative;
-webkit-transition: all .1s ease-out;
transition: all .1s ease-out;
}
.buttons:active,
.buttons:focus,
.buttons:hover {
box-shadow: 0 0 4px rgba(0, 0, 0, .14), 0 4px 8px rgba(0, 0, 0, .28);
}
.buttons:not(:last-child) {
width: 40px;
height: 40px;
margin: 20px auto 0;
opacity: 0;
-webkit-transform: translateY(50px);
-ms-transform: translateY(50px);
transform: translateY(50px);
}
.container:hover .buttons:not(:last-child) {
opacity: 1;
-webkit-transform: none;
-ms-transform: none;
transform: none;
margin: 15px auto 0;
}
/* Unessential styling for sliding up buttons at differnt speeds */
.buttons:nth-last-child(1) {
-webkit-transition-delay: 25ms;
transition-delay: 25ms; background-image: url('http://cbwconline.com/IMG/Share.svg'); background-size: contain; } .buttons:not(:last-child):nth-last-child(2) { -webkit-transition-delay: 50ms; transition-delay: 20ms; background-image: url('http://cbwconline.com/IMG/Facebook-Flat.png');
background-size: contain; } .buttons:not(:last-child):nth-last-child(3) { -webkit-transition-delay: 75ms; transition-delay: 40ms; background-image: url('http://cbwconline.com/IMG/Twitter-Flat.png'); background-size: contain; } .buttons:not(:last-child):nth-last-child(4)
{
-webkit-transition-delay: 100ms; transition-delay: 60ms; background-image: url('http://cbwconline.com/IMG/Google%20Plus.svg'); background-size: contain; } /* Show tooltip content on hover *
[tooltip]: before {
bottom: 25%;
font-family: arial;
font-weight: 600;
border-radius: 2px;
background: #585858;
color: #fff;
content: attr(tooltip);
font-size: 12px;
visibility: hidden;
opacity: 0;
padding: 5px 7px;
margin-right: 12px;
position: absolute;
right: 100%;
white-space: nowrap;
}
[tooltip]:hover:before,
[tooltip]:hover:after {
visibility: visible;
opacity: 1;
}
<body>
<h1>Simple Share FAB</h1>
<p class="credits">
<a href="http://codepen.io/koenigsegg1" target="_blank">
<img src="http://s3-us-west-2.amazonaws.com/s.cdpn.io/343394/profile/profile-80_3.jpg" />
</a>
<br />Pen by Kyle Lavery (#koenigsegg1)</p>
<nav class="container">
<a class="buttons" tooltip="Share" href="#"></a>
</nav>
</body>
In the demo, you can see that if you hover on the share button, the other buttons pop up, and each button has a different tooltip.
Now, what I want to do is make all those tooltips visible as soon as the share button is hovered, instead of displaying them when that particular button is hovered. Is it possible to do using pure css? I can't seem to figure it out.
It is simply a matter of toggling the visibility value of the CSS elements for [tooltip] attribute.
Also, remove the [tooltip]:hover:before and [tooltip]:hover:after properties.
#import url(https://fonts.googleapis.com/css?family=Roboto:100,200,300,400,500);
body {
background: #00BCD4;
min-height: 100vh;
overflow: hidden;
font-family: Roboto;
color: #fff;
}
h1 {
font: 200 60px Roboto;
text-align: center;
}
p.credits {
text-align: center;
margin-top: 100px;
}
.credits img {
border-radius: 50%;
width: 100px;
}
.container {
bottom: 0;
position: fixed;
margin: 1em;
right: 0px;
}
.buttons {
box-shadow: 0px 5px 11px -2px rgba(0, 0, 0, 0.18), 0px 4px 12px -7px rgba(0, 0, 0, 0.15);
border-radius: 50%;
display: block;
width: 56px;
height: 56px;
margin: 20px auto 0;
position: relative;
-webkit-transition: all .1s ease-out;
transition: all .1s ease-out;
}
.buttons:active,
.buttons:focus,
.buttons:hover {
box-shadow: 0 0 4px rgba(0, 0, 0, .14), 0 4px 8px rgba(0, 0, 0, .28);
}
.buttons:not(:last-child) {
width: 40px;
height: 40px;
margin: 20px auto 0;
opacity: 0;
-webkit-transform: translateY(50px);
-ms-transform: translateY(50px);
transform: translateY(50px);
}
.container:hover .buttons:not(:last-child) {
opacity: 1;
-webkit-transform: none;
-ms-transform: none;
transform: none;
margin: 15px auto 0;
}
/* Unessential styling for sliding up buttons at differnt speeds */
.buttons:nth-last-child(1) {
-webkit-transition-delay: 25ms;
transition-delay: 25ms;
background-image: url('http://cbwconline.com/IMG/Share.svg');
background-size: contain;
}
.buttons:not(:last-child):nth-last-child(2) {
-webkit-transition-delay: 50ms;
transition-delay: 20ms;
background-image: url('http://cbwconline.com/IMG/Facebook-Flat.png');
background-size: contain;
}
.buttons:not(:last-child):nth-last-child(3) {
-webkit-transition-delay: 75ms;
transition-delay: 40ms;
background-image: url('http://cbwconline.com/IMG/Twitter-Flat.png');
background-size: contain;
}
.buttons:not(:last-child):nth-last-child(4) {
-webkit-transition-delay: 100ms;
transition-delay: 60ms;
background-image: url('http://cbwconline.com/IMG/Google%20Plus.svg');
background-size: contain;
}
/* Show tooltip content on hover */
[tooltip]:before {
bottom: 25%;
font-family: arial;
font-weight: 600;
border-radius: 2px;
background: #585858;
color: #fff;
content: attr(tooltip);
font-size: 12px;
/*
visibility: hidden;
opacity: 0;
*/
padding: 5px 7px;
margin-right: 12px;
position: absolute;
right: 100%;
white-space: nowrap;
}
<body>
<h1>Simple Share FAB</h1>
<p class="credits">
<a href="http://codepen.io/koenigsegg1" target="_blank">
<img src="http://s3-us-west-2.amazonaws.com/s.cdpn.io/343394/profile/profile-80_3.jpg" />
</a>
<br />Pen by Kyle Lavery (#koenigsegg1)</p>
<nav class="container">
<a class="buttons" tooltip="Share" href="#"></a>
</nav>
</body>
I am having trouble vertically aligning the 's text inside a div.
This is what I have. I need to center "Next" inside the blue box:
#import url(http://fonts.googleapis.com/css?family=Muli);
/*Makes the little side arrow*/
.open {
position: fixed;
width: 100px;
height: 40px;
left: 50%;
top: -1000px;
margin-left: -80px;
margin-top: -30px;
border: 1px solid #ccc;
background-color: #fff;
border-radius: 6px;
padding: 10px 30px;
color: #444;
transition: all ease-out 0.6s;
}
.open:hover {
border: 1px solid #aaa;
box-shadow: 0 0 8px #ccc inset;
transition: all ease-out 0.6s;
}
.tutorial-box {
position: fixed;
width: 400px;
height: 238px;
top: 75px;
background-color: #F3F3F3;
border-radius: 6px;
box-shadow: 0px 0px 24px rgba(0, 0, 0, 0.4);
}
.slider-turn p, .tutorial-box h1{
margin-left: 10px;
}
.tutorial-box:before {
content: '';
position: absolute;
left: -14px;
top: 28px;
border-style: solid;
border-width: 10px 14px 10px 0;
border-color: rgba(0, 0, 0, 0) #f3f3f3 rgba(0, 0, 0, 0) rgba(0, 0, 0, 0);
}
.tutorial-box p {
width: 350px;
font-size: 16px;
color: #a8aab2;
font-weight: 400;
line-height: 28px;
float: left;
margin: 0;
}
.tutorial-box .bottom {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
width: 100%;
bottom: 0;
position: absolute;
}
.tutorial-box .bottom .btn-2 {
flex: 3;
-webkit-flex: 3;
-ms-flex: 3;
width: 100%;
height: 54px;
background-color: #373942;
border-bottom-left-radius: 6px;
display: flex;
}
.tutorial-box .bottom span {
flex: 1;
-webkit-flex: 1;
-ms-flex: 1;
line-height: 54px;
color: #fff;
margin-left: 25px;
font-size: 18px;
}
.next {
text-decoration: none;
display: inline-block;
vertical-align: middle;
text-align: center;
flex: 1;
background-color: #6cb5f3;
border: 0;
margin: 0;
padding: 0;
text-transform: uppercase;
color: #fff;
font-weight: bold;
border-bottom-right-radius: 6px;
cursor: pointer;
transition: all .3s;
}
.next:hover {
text-decoration: none;
background-color: #6BA5D6;
transition: all .3s;
}
.next:active {
text-decoration: none;
background-color: #5F8AAF;
}
.slider-tutorial-box {
width: 350px;
margin: 0 25px;
overflow: hidden;
}
.slider-turn {
width: 10000px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- TUTORIAL -->
<div class="tutorial-box">
<h1>Welcome</h1>
<span class="close"></span>
<div class="slider-container">
<div class="slider-turn">
<p>
Here, under the Company tab, is where you will do most of the company managment.<br>
</p>
</div>
</div>
<div class="bottom">
<div class="btn-2">
<span>Step 2/?</span>
</div>
Next
</div>
</div>
Please let me know how I can center the text vertically to the center of the div.
Thank you very much. Let me know if I wasn't clear enough.
Seems like you already did that for .tutorial-box .bottom span so, do the same thing for .next
.next{
line-height: 54px;
}
the simplest and possibly most easy way would be to add the 'center' and '/center' tag before and after the text you want, and after each letter use '/br' to move to the next line. this will add some bulk, but would be considerably easier than other methods.
<center>
'letter'</br>'next letter'</br>'next letter'</br>
</center>
repeating the letter and break for all letters
alternatively, you could also add "div" tags around the "a" tag. you would have to modify the 'height' and 'width' to make it vertical for you. I would use px for this and not '%' or 'em'. add this to them:
<div style="height: /* modify this */100px; width: /* and this*/20px;">
Next
</div>
this may not be AS compatible cross platform though.
Like this:
.next {
position: relative;
top: 50%;
transform: translateY(-50%);
}
A nice trick that works both vertically and horizontally.