Content showing over the top of tooltip - html

I am setting a tooltip with content on my website. The content outside the tooltip is showing over one of my tooltip
Demo Link:
Code:
/*
You want a simple and fancy tooltip?
Just copy all [data-tooltip] blocks:
*/
[data-tooltip] {
position: relative;
z-index: 10;
}
/* Positioning and visibility settings of the tooltip */
[data-tooltip]:before,
[data-tooltip]:after {
position: absolute;
visibility: hidden;
opacity: 0;
left: 50%;
bottom: calc(100% + 5px);
/* 5px is the size of the arrow */
pointer-events: none;
transition: 0.2s;
will-change: transform;
}
/* The actual tooltip with a dynamic width */
[data-tooltip]:before {
content: attr(data-tooltip);
padding: 10px 18px;
min-width: 50px;
max-width: 300px;
width: max-content;
width: -moz-max-content;
border-radius: 6px;
font-size: 14px;
background-color: rgba(59, 72, 80, 0.9);
background-image: linear-gradient(30deg, rgba(59, 72, 80, 0.44), rgba(59, 68, 75, 0.44), rgba(60, 82, 88, 0.44));
box-shadow: 0px 0px 24px rgba(0, 0, 0, 0.2);
color: #fff;
text-align: center;
white-space: pre-wrap;
transform: translate(-50%, -5px) scale(0.5);
}
/* Tooltip arrow */
[data-tooltip]:after {
content: '';
border-style: solid;
border-width: 5px 5px 0px 5px;
/* CSS triangle */
border-color: rgba(55, 64, 70, 0.9) transparent transparent transparent;
transition-duration: 0s;
/* If the mouse leaves the element,
the transition effects for the
tooltip arrow are "turned off" */
transform-origin: top;
/* Orientation setting for the
slide-down effect */
transform: translateX(-50%) scaleY(0);
}
/* Tooltip becomes visible at hover */
[data-tooltip]:hover:before,
[data-tooltip]:hover:after {
visibility: visible;
opacity: 1;
}
/* Scales from 0.5 to 1 -> grow effect */
[data-tooltip]:hover:before {
transition-delay: 0.3s;
transform: translate(-50%, -5px) scale(1);
}
/*
Arrow slide down effect only on mouseenter (NOT on mouseleave)
*/
[data-tooltip]:hover:after {
transition-delay: 0.5s;
/* Starting after the grow effect */
transition-duration: 0.2s;
transform: translateX(-50%) scaleY(1);
}
/*
That's it.
*/
/*
If you want some adjustability
here are some orientation settings you can use:
*/
/* LEFT */
/* Tooltip + arrow */
[data-tooltip-location="left"]:before,
[data-tooltip-location="left"]:after {
left: auto;
right: calc(100% + 5px);
bottom: 50%;
}
/* Tooltip */
[data-tooltip-location="left"]:before {
transform: translate(-5px, 50%) scale(0.5);
}
[data-tooltip-location="left"]:hover:before {
transform: translate(-5px, 50%) scale(1);
}
/* Arrow */
/* BOTTOM */
[data-tooltip-location="bottom"]:before,
[data-tooltip-location="bottom"]:after {
top: calc(100% + 5px);
bottom: auto;
}
[data-tooltip-location="bottom"]:before {
transform: translate(-50%, 5px) scale(0.5);
}
[data-tooltip-location="bottom"]:hover:before {
transform: translate(-50%, 5px) scale(1);
}
[data-tooltip-location="bottom"]:after {
border-width: 0px 5px 5px 5px;
border-color: transparent transparent rgba(55, 64, 70, 0.9) transparent;
transform-origin: bottom;
}
/* Settings that make the pen look nicer */
html {
width: 100%;
height: 100%;
font-family: 'Roboto', sans-serif;
color: white;
font-size: 1.2em;
background: linear-gradient(45deg, #243949, #2cacd1, #35eb93);
background-size: 120% 120%;
animation: moveFocus 5s ease infinite alternate;
}
#keyframes moveFocus {
0% {
background-position: 0% 100%
}
100% {
background-position: 100% 0%
}
}
body {
background: none;
display: flex;
flex-direction: column;
height: 100%;
margin: 0;
}
main {
padding: 0 4%;
display: flex;
flex-direction: row;
margin: auto 0;
}
button {
margin: 0;
padding: 0.7rem 1.4rem;
cursor: pointer;
text-align: center;
border: none;
border-radius: 4px;
outline: inherit;
text-decoration: none;
font-family: Roboto, sans-serif;
font-size: 0.7em;
background-color: rgba(174, 184, 192, 0.55);
color: white;
-webkit-appearance: none;
-moz-appearance: none;
transition: background 350ms ease-in-out, transform 150ms ease;
}
button:hover {
background-color: #484f56;
}
button:active {
transform: scale(0.98);
}
button:focus {
box-shadow: 0 0 2px 2px #298bcf;
}
button::-moz-focus-inner {
border: 0;
}
.example-elements {
flex-grow: 1;
display: flex;
flex-direction: column;
align-items: center;
align-content: center;
justify-content: center;
text-align: center;
padding-right: 4%;
}
.example-elements p {
padding: 6px;
display: inline-block;
margin-bottom: 5%;
color: #fff;
}
.example-elements p:hover {
border-left: 1px solid lightgrey;
border-right: 1px solid lightgrey;
padding-left: 5px;
padding-right: 5px;
}
.example-elements a {
margin-left: 6px;
margin-bottom: calc(5% + 10px);
color: #76daff;
text-decoration: none;
}
.example-elements a:hover {
margin-bottom: calc(5% + 9px);
border-bottom: 1px solid #76daff;
}
.example-elements button {
margin-bottom: 20px;
}
.info-wrapper {
flex-grow: 8;
display: flex;
flex-direction: column;
justify-content: center;
text-align: justify;
padding-left: 6%;
border-left: 3px solid #35ea95;
}
.info-wrapper p {
color: rgba(255, 255, 255, 0.69);
}
.info-wrapper p {
max-width: 600px;
text-align: justify;
}
.info-wrapper .title-question {
display: block;
color: #fff;
font-size: 1.36em;
font-weight: 500;
padding-bottom: 24px;
}
#media (max-height: 450px) {
main {
margin: 2rem 0;
}
}
#media (max-width: 800px) {
html {
font-size: 0.9em;
}
}
/* Thumbnail settings */
#media (max-width: 750px) {
html {
animation-duration: 0.6s;
font-size: 1em;
}
body {
display: flex;
background: none;
height: 100%;
margin: 0px;
}
main {
font-size: 1.1em;
padding: 6%;
}
.info-wrapper p:before,
.info-wrapper p:after {
display: none;
}
.example-elements {
max-width: 150px;
font-size: 22px;
}
.example-elements a,
button {
display: none;
}
.example-elements p:before,
.example-elements p:after {
visibility: visible;
opacity: 1;
}
.example-elements p:before {
content: "Tooltip";
font-size: 20px;
transform: translate(-50%, -5px) scale(1);
}
.example-elements p:after {
transform: translate(-50%, -1px) scaleY(1);
}
[data-tooltip]:after {
bottom: calc(100% + 3px);
}
[data-tooltip]:after {
border-width: 7px 7px 0px 7px;
}
}
<main>
<div class="info-wrapper">
<p>
<span class="title-question">
You want a simple, animated & easy-to-use tooltip?
</span>
<span>
Just copy all the CSS declarations blocks starting with
<code>[data-tooltip].</code>
</span>
</p>
<p data-tooltip="This is an example of a super long tooltip text that goes over multiple lines.
Note: The tooltip size is dynamically adjusted to the content. However, a minimum and a maximum width are defined." data-tooltip-location="bottom">
To use the tooltip, simply add the attribute »data-tooltip« with the desired text to an element. P.S. Hover over me to see a long tooltip.
</p>
<p data-tooltip="This is an example of a super long tooltip text that goes over multiple lines.
Note: The tooltip size is dynamically adjusted to the content. However, a minimum and a maximum width are defined." data-tooltip-location="top">
To use the tooltip, simply add the attribute »data-tooltip« with the desired text to an element. P.S. Hover over me to see a long tooltip.
</p>
</div>
</main>

Remove z-index to [data-tooltip]
Add z-index to [data-tooltip]:before, [data-tooltip]:after
[data-tooltip] {
position: relative;
/*z-index:1; */ /* Remove this */
}
[data-tooltip]:before,
[data-tooltip]:after {
z-index:1;
}

Related

animation lagging in Firefox

I am trying to animate my logo with CSS.
It works fine in browsers like Opera, Chrome, Edge but lags in Firefox. I tried adding the vendor prefixes like -moz- , -o-, -webkit- to animation, animation-delay and transform but still it is lagging only in Firefox.
Here is the fiddle link click here
scrollbar css also not working only in Firefox
html::-webkit-scrollbar {
width: 10px;
}
html::-webkit-scrollbar-track {
background-color: white;
}
html::-webkit-scrollbar-thumb {
background: var(--colorMain);
}
html::-moz-scrollbar {
width: 10px;
}
html::-moz-scrollbar-track {
background-color: white;
}
html::-moz-scrollbar-thumb {
background: var(--colorMain);
}
First you need to remove the display: contents; in your .wrapper span and the animation will play smoothly.
.wrapper span {
/* display: contents; */
-webkit-text-stroke-width: 1.5px;
text-shadow: 0 0px var(--brShadow), 0 0px var(--tlShadow);
transform: translate(0, 100%) rotate(2deg);
animation: jump 2s ease-in-out infinite;
color: var(--colorMain);
}
To solve the second problem, add scrollbar-color: var(--colorMain) white; property to the html class, because Firefox scrollbar to customize differently.
html {
font-size: 63.5%;
overflow-x: hidden;
scroll-padding-top: 6rem;
scroll-behavior: smooth;
text-decoration: none;
scrollbar-color: var(--colorMain) white; /* new line */
}
:root {
--colorMain: #4784e6;
}
* {
font-family: 'Nunito', sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
outline: none;
border: none;
text-decoration: none;
}
html {
font-size: 63.5%;
overflow-x: hidden;
scroll-padding-top: 6rem;
scroll-behavior: smooth;
text-decoration: none;
scrollbar-color: var(--colorMain) white; /* new line */
}
html::-webkit-scrollbar {
width: 10px;
}
html::-webkit-scrollbar-track {
background-color: white;
}
html::-webkit-scrollbar-thumb {
background: var(--colorMain);
}
/* header section */
section {
padding: 5rem 10%;
}
a {
text-decoration: none;
}
.header span {
font-size: 3rem;
background: rgba(255, 255, 255, 0.2);
color: var(--colorMain);
border-radius: 0.5rem;
padding: 0.1rem 0.1rem;
}
.wrapper {
width: max-content;
margin-left: 2rem;
margin-right: 2rem;
}
.wrapper span {
/* display: contents; */
-webkit-text-stroke-width: 1.5px;
text-shadow: 0 0px var(--brShadow), 0 0px var(--tlShadow);
transform: translate(0, 100%) rotate(2deg);
animation: jump 2s ease-in-out infinite;
color: var(--colorMain);
}
.wrapper span:nth-child(1) {
animation-delay: 120ms;
}
.wrapper span:nth-child(2) {
animation-delay: 240ms;
}
.wrapper span:nth-child(3) {
animation-delay: 360ms;
}
.wrapper span:nth-child(4) {
animation-delay: 480ms;
}
.wrapper span:nth-child(5) {
animation-delay: 600ms;
}
.wrapper span:nth-child(6) {
animation-delay: 720ms;
}
#keyframes jump {
33% {
text-shadow: 0 10px rgb(64, 206, 206), 0 15px #aadef2;
}
50% {
transform: translate(0, 0) rotate(-4deg);
text-shadow: 0 0px #8fc0a9, 0 0px #84a9ac;
}
66.67% {
text-shadow: 0 -10px rgb(64, 206, 206), 0 -15px #8fc0a9;
}
}
<section class="header">
<a href="#" class="logo text-decoration-none">
<div class="wrapper">
<span>T</span>
<span>R</span>
<span>A</span>
<span>V</span>
<span>E</span>
<span>L</span>
</div>
</a>
</section>

How to show text from bottom when Hover

I am looking for some css trick to show an element (already hidden) from bottom to a it's normal position.
This is a screenshot how it should be:
i did this but it doesn't work as i expected and like what is on the screenshot, when you hover, the text should slide to the top. i made that, but with this method i did, the title is a little bit far from the text bellow ( screenshot )
Please can somebody help to find a lite solution
Please can somebody help me to find a lite solution
.hebergements__container {
position: relative;
display: flex;
margin: auto;
width: 30rem;
}
.hebergements__container::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #ccc;
z-index: 1;
}
.hebergements__container:hover .hebergements__desc {
opacity: 1;
height: auto;
-webkit-transition-delay: 0.05s;
transition-delay: 0.05s;
-webkit-transition-duration: 0.35s;
transition-duration: 0.35s;
}
.hebergements__container:hover .hebergements__desc, .hebergements__container:hover .hebergements__title {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.hebergements__container > img {
width: 100%;
height: 100%;
object-fit: cover;
overflow: hidden;
}
.hebergements__content {
display: flex;
flex-direction: column;
justify-content: flex-end;
min-height: 41.8rem;
padding-left: 2.5rem;
padding-bottom: 2.8rem;
z-index: 1;
}
.hebergements__content .hebergements__title {
margin-bottom: 1rem;
}
.hebergements__content .hebergements__desc {
color: #fff;
}
.hebergements__content .hebergements__desc ul:first-child {
margin-top: 0;
}
.hebergements__content .hebergements__startFrom {
font-size: 1.1rem;
color: #fff;
margin-bottom: -0.8rem;
}
.hebergements__content .hebergements__price {
color: #fff;
font-size: 2.4rem;
font-weight: fontWeight(extra-bold);
}
.hebergements__content .hebergements__price .price-unity {
font-size: 1.6rem;
}
.hebergements__content .hebergements__pension {
color: #fff;
font-size: 1rem;
margin-top: 0.3rem;
}
.hebergements__content {
position: absolute;
bottom: 0;
left: 0;
padding: 2em;
width: 100%;
height: 50%;
}
.hebergements__content .hebergements__title, .hebergements__content .hebergements__desc {
transform: translate3d(0, 40px, 0);
}
.hebergements__content .hebergements__title {
transition: transform 0.35s;
}
.hebergements__content .hebergements__desc {
color: rgba(255, 255, 255, 0.8);
opacity: 0;
transition: opacity 0.2s, transform 0.35s;
}
.hebergements__container:hover .hebergements__desc {
opacity: 1;
}
.hebergements__container:hover .hebergements__title, .hebergements__container:hover .hebergements__desc {
transform: translate3d(0, 0, 0);
}
.hebergements__container:hover .hebergements__desc {
transition-delay: 0.05s;
transition-duration: 0.35s;
}
<div class="container product-hebergements">
<div class="hebergements__container">
<img src="https://tympanus.net/Development/HoverEffectIdeas/img/12.jpg" alt="img12"/>
<div class="hebergements__content">
<h2 class="hebergements__title">
Votre séjour en Club
</h2>
<div class="hebergements__desc">
<ul>
<li>En chambre ou en appartement</li>
<li>Capacité à partir de 2 personnes jusqu'à 10 personnes.</li>
<li>Formule pension demi pension inclus</li>
<li>Profitez des activités...Services</li>
</ul>
</div>
<div class="hebergements__bottom">
<div class="hebergements__pension">
8 jours/7 nuits . Pension complète. Prix par pers.
</div>
</div>
</div>
</div>
</div>
I'm not using my computer right now but, I think, to create your animation, you have to create a #keyframe. Basically, your 3 lines are hidden, and, when you hover it, a new style must be added, with the keyframe (and the visibility visible).
Your keyframe must contain something like :
Transform: translateX (you have to make your div go to the top)
Animation fill mode forward
This is not complete, but you got the idea.
Here is my try
.hebergements__container {
position: relative;
display: flex;
margin: auto;
width: 30rem;
}
.hebergements__container::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #ccc;
z-index: 1;
}
.hebergements__container:hover .hebergements__desc {
opacity: 1;
height: auto;
-webkit-transition-delay: 0.05s;
transition-delay: 0.05s;
-webkit-transition-duration: 0.35s;
transition-duration: 0.35s;
}
.hebergements__container:hover .hebergements__desc, .hebergements__container:hover .hebergements__title {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.hebergements__container > img {
width: 100%;
height: 100%;
object-fit: cover;
overflow: hidden;
}
.hebergements__content {
display: flex;
flex-direction: column;
justify-content: flex-end;
min-height: 41.8rem;
padding-left: 2.5rem;
padding-bottom: 2.8rem;
z-index: 1;
overflow: hidden; /* added this line */
}
.hebergements__content .hebergements__title {
margin-bottom: 1rem;
}
.hebergements__content .hebergements__desc {
color: #fff;
}
.hebergements__content .hebergements__desc ul:first-child {
margin-top: 0;
}
.hebergements__content .hebergements__startFrom {
font-size: 1.1rem;
color: #fff;
margin-bottom: -0.8rem;
}
.hebergements__content .hebergements__price {
color: #fff;
font-size: 2.4rem;
font-weight: fontWeight(extra-bold);
}
.hebergements__content .hebergements__price .price-unity {
font-size: 1.6rem;
}
.hebergements__content .hebergements__pension {
color: #fff;
font-size: 1rem;
margin-top: 0.3rem;
}
.hebergements__content {
position: absolute;
bottom: 0;
left: 0;
padding: 2em;
width: 100%;
height: 50%;
}
.hebergements__content .hebergements__title, .hebergements__content .hebergements__desc {
transform: translate3d(0, 40px, 0);
}
.hebergements__content .hebergements__title {
transition: transform 0.35s;
}
.hebergements__content .hebergements__desc {
color: rgba(255, 255, 255, 0.8);
opacity: 0;
transition: opacity 0.2s, transform 0.35s;
height: 2rem; /* added this line */
}
.hebergements__container:hover .hebergements__desc {
opacity: 1;
}
.hebergements__container:hover .hebergements__title, .hebergements__container:hover .hebergements__desc {
transform: translate3d(0, 0, 0);
}
.hebergements__container:hover .hebergements__desc {
transition-delay: 0.05s;
transition-duration: 0.35s;
height: auto; /* added this line */
}
<div class="container product-hebergements">
<div class="hebergements__container">
<img src="https://tympanus.net/Development/HoverEffectIdeas/img/12.jpg" alt="img12"/>
<div class="hebergements__content">
<h2 class="hebergements__title">
Votre séjour en Club
</h2>
<div class="hebergements__desc">
<ul>
<li>En chambre ou en appartement</li>
<li>Capacité à partir de 2 personnes jusqu'à 10 personnes.</li>
<li>Formule pension demi pension inclus</li>
<li>Profitez des activités...Services</li>
</ul>
</div>
<div class="hebergements__bottom">
<div class="hebergements__pension">
8 jours/7 nuits . Pension complète. Prix par pers.
</div>
</div>
</div>
</div>
</div>
Instead of debugging your code trying to workaround/find your errors, I created a 'generic' animated card based on your code and requirement.
The entire mechanism hinges on flexbox behaviour:
FBL column containers, for easy positioning
FBL content moved to flex-end. This forces all elements to the bottom of the card.
FBL 'flex-basis' animated .header from 0% to 40%. As the un-hovered value is 0% all elements reside at the bottom of the card. When changed to a higher value (< 40%), the .header grows, pushing itself towards the top of the card. This is the single main behaviour we need.
Animating the properties of various elements from some initial value to a hover state value moves/shows/sizes the end result.
BONUS some card hover/click action I always use.
I have commented the code, which makes reading a bit easier...
The Snippet
/* for debugging, remove/disable when done */
/* * { outline: 1px dashed }/**/
/***********************/
/* element definitions */
/***********************/
.card {
position: relative;
margin: 0 auto;
width: 30rem; /* not responsive!! */
aspect-ratio: 1/1;
}
.card > * { /* picture and content */
position: absolute;
inset: 0; /* stretched to fill parent (T/R/B/L) */
}
/* background picture under all content, stretched to fit parent */
.card .bg-pic { z-index: -1 }
.card .bg-pic img { display: block; width: 100%; height: 100%; object-fit: cover }
/* Flexbox container over card background image */
.card .inner {
z-index: 1;
display: flex; flex-flow: column wrap;
padding: 1rem;
justify-content: flex-end; /* move all elements to .inner bottom */
}
.card .inner > * {
/* all card .inner elements are FBL column containers */
display: flex; flex-flow: column wrap;
}
/********************************/
/* All hover animation settings */
/********************************/
/*
element defaults before animation with transitions set,
followed by animation settings.
*/
.card {
/* trasition properties, delay, behaviour */
--tr-f: all 0.05s ease-in-out; /* fast transition */
--tr-s: all 0.35s ease-in-out; /* slow */
}
.card .header {
flex-basis: 0%; /* makes it shrink to HTML default */
font-size: 1.5rem;
transition: var(--tr-f);
}
.card:hover .header {
/* When content/footer tend to wrap, fiddle with below 'flex-basis' < 40% */
flex-basis: 40%; /* makes it stretch to fill 40% */
font-size: 2rem;
text-align: center;
}
.card .bg-pic {
opacity: 0.5;
transition: var(--tr-s);
}
.card:hover .bg-pic {
opacity: 1;
}
.card .content {
/* hides fading text under pricing */
overflow: hidden; /* disable to test */
height : 0px;
opacity: 0;
transition: var(--tr-s);
}
.card:hover .content {
height : auto;
opacity: 1;
}
/*************/
/* Eye-candy */
/*************/
body { font-size: 1rem }
ul, li { padding: 0; list-style-type: none }
.card > * {
/* obfuscate picture for testing */
background-color: hsl(0,0%,0%,.5);/* remove me */
color: hsl(0,0%,100%,1);
cursor: pointer;
}
.title { font-size: 1.5rem }
.prix { font-size: 2.4rem; font-weight: bold }
.unit { font-size: 1.6rem }
/* BONUS: card hover/click animation */
.card {
/* GMD elevation 1dp */
box-shadow: 0px 2px 1px -1px rgba(0,0,0,.20),
0px 1px 1px 0px rgba(0,0,0,.14),
0px 1px 3px 0px rgba(0,0,0,.12);
}
.card:hover {
transform: scale(1.01);
/* GMD elevation 3dp */
box-shadow: 0px 3px 3px -2px rgba(0,0,0,.20),
0px 3px 4px 0px rgba(0,0,0,.14),
0px 1px 8px 0px rgba(0,0,0,.12);
}
.card:active:not(:focus), .card:focus {
transform: scale(1);
}
<div class="card">
<div class="bg-pic"><img src="https://picsum.photos/320" alt="" aria-hidden="true" /></div>
<div class="inner">
<div class="header">
<div>Votre séjour en Club</div>
</div>
<div class="content">
<ul>
<li class="title">some alt title</li>
<li>En chambre ou en appartement</li>
<li>Capacité à partir de 2 personnes jusqu'à 10 personnes.</li>
<li>Formule pension demi pension inclus</li>
<li>Profitez des activités...Services</li>
</ul>
</div>
<div class="footer">
<span>A partir de</span>
<span class="prix">529<span class="unit">€</span></span>
<div>8 jours/7 nuits . Pension complète. Prix par pers.</div>
</div>
</div>
</div>

How to move the men icon to the right side and remove the top white space

I just downloaded an HTML and CSS template online and want to modify the code to adjust the hamburger menu icon to the right and have the menu slide from the right side but I had no idea about which part I should change
I have attached a screenshot of the interface below for reference. Thanks!
/*menu*/
#menuToggle
{
display: block;
position: relative;
top: 50px;
left: 50px;
z-index: 1;
-webkit-user-select: none;
user-select: none;
}
#menuToggle a
{
text-decoration: none;
color: #232323;
transition: color 0.3s ease;
}
#menuToggle a:hover
{
color: tomato;
}
#menuToggle input
{
display: block;
width: 40px;
height: 32px;
position: absolute;
top: -7px;
left: -5px;
cursor: pointer;
opacity: 0; /* hide this */
z-index: 2; /* and place it over the hamburger */
-webkit-touch-callout: none;
}
/*
* Just a quick hamburger
*/
#menuToggle span
{
display: block;
width: 33px;
height: 4px;
margin-bottom: 5px;
position: relative;
background: #cdcdcd;
border-radius: 3px;
z-index: 1;
transform-origin: 4px 0px;
transition: transform 0.5s cubic-bezier(0.77,0.2,0.05,1.0),
background 0.5s cubic-bezier(0.77,0.2,0.05,1.0),
opacity 0.55s ease;
}
#menuToggle span:first-child
{
transform-origin: 0% 0%;
}
#menuToggle span:nth-last-child(2)
{
transform-origin: 0% 100%;
}
/*
* Transform all the slices of hamburger
* into a crossmark.
*/
#menuToggle input:checked ~ span
{
opacity: 1;
transform: rotate(45deg) translate(-2px, -1px);
background: #ffffff;
}
/*
* But let's hide the middle one.
*/
#menuToggle input:checked ~ span:nth-last-child(3)
{
opacity: 0;
transform: rotate(0deg) scale(0.2, 0.2);
}
/*
* Ohyeah and the last one should go the other direction
*/
#menuToggle input:checked ~ span:nth-last-child(2)
{
transform: rotate(-45deg) translate(0, -1px);
}
/*
* Make this absolute positioned
* at the top left of the screen
*/
#menu
{
position: absolute;
width: 300px;
margin: -100px 0 0 -50px;
padding: 50px;
padding-top: 125px;
background: #ededed;
list-style-type: none;
-webkit-font-smoothing: antialiased;
/* to stop flickering of text in safari */
transform-origin: 0% 0%;
transform: translate(-100%, 0);
transition: transform 0.5s cubic-bezier(0.77,0.2,0.05,1.0);
}
#menu li
{
padding: 10px 0;
font-size: 22px;
}
/*
* And let's slide it in from the left
*/
#menuToggle input:checked ~ ul
{
transform: none;
}
/*----------------------------------menu----------------------------*/
.section {
position: relative;
height: 100vh;
}
.section .section-center {
position: absolute;
top: 50%;
left: 0;
right: 0;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
}
#booking {
font-family: 'Montserrat', sans-serif;
background-image: url('../img/dog.jpeg');
background-size: cover;
background-position: center;
}
#booking::before {
content: '';
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
background: rgba(143, 215, 230, 0.6);
}
.booking-form {
background-color: #fff;
padding: 60px 20px;
-webkit-box-shadow: 0px 5px 20px -5px rgba(0, 0, 0, 0.3);
box-shadow: 0px 5px 20px -5px rgba(0, 0, 0, 0.3);
border-radius: 4px;
}
.booking-form .form-group {
position: relative;
margin-bottom: 30px;
}
.booking-form .form-control {
background-color: #ebecee;
border-radius: 4px;
border: none;
height: 40px;
-webkit-box-shadow: none;
box-shadow: none;
color: #3e485c;
font-size: 14x;
}
.booking-form .form-control::-webkit-input-placeholder {
color: rgba(62, 72, 92, 0.3);
}
.booking-form .form-control:-ms-input-placeholder {
color: rgba(62, 72, 92, 0.3);
}
.booking-form .form-control::placeholder {
color: rgba(62, 72, 92, 0.3);
}
.booking-form input[type="date"].form-control:invalid {
color: rgba(62, 72, 92, 0.3);
}
.booking-form select.form-control {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
.booking-form select.form-control+.select-arrow {
position: absolute;
right: 0px;
bottom: 4px;
width: 40px;
line-height: 32px;
height: 32px;
text-align: center;
pointer-events: none;
color: rgba(62, 72, 92, 0.3);
font-size: 14px;
}
.booking-form select.form-control+.select-arrow:after {
content: '\279C';
display: block;
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.booking-form .form-label {
display: inline-block;
color: #3e485c;
font-weight: 700;
margin-bottom: 6px;
margin-left: 7px;
}
.booking-form .submit-btn {
display: inline-block;
color: #fff;
background-color: #1e62d8;
font-weight: 700;
padding: 14px 30px;
border-radius: 4px;
border: none;
-webkit-transition: 0.2s all;
transition: 0.2s all;
}
.booking-form .submit-btn:hover,
.booking-form .submit-btn:focus {
opacity: 0.9;
}
.booking-cta {
margin-top: 80px;
margin-bottom: 30px;
}
.booking-cta h1 {
font-size: 52px;
text-transform: uppercase;
color: #fff;
font-weight: 700;
}
.booking-cta p {
font-size: 20px;
color: rgba(255, 255, 255, 0.8);
}
footer {
position: relative;
height: 0px;
width: 100%;
background-color: #333333;
}
p.copyright {
position: absolute;
width: 100%;
color: #fff;
line-height: 40px;
font-size: 0.7em;
text-align: center;
bottom:0;
}
HTML Code:
<nav role="navigation">
<div id="menuToggle">
<!--
A fake / hidden checkbox is used as click reciever,
so you can use the :checked selector on it.
-->
<input type="checkbox" />
<!--
Some spans to act as a hamburger.
They are acting like a real hamburger,
not that McDonalds stuff.
-->
<span></span>
<span></span>
<span></span>
<ul id="menu">
<li>Home</li>
<li>About</li>
<li>Info</li>
<li>Contact</li>
</ul>
</div>
</nav>
<div id="booking" class="section">
<div class="section-center">
<div class="container">
<div class="row">
<div class="col-md-7 col-md-push-5">
<div class="booking-cta">
<h1>Bring Your Pet to Work</h1>
<p>Caring and Loving Pet service
</p>
</div>
</div>
<div class="col-md-4 col-md-pull-7">
<div class="booking-form">
<form>
<div class="form-group">
<span class="form-label">Where do you work? </span>
<input class="form-control" type="text" placeholder="Enter an address or zipcode">
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<span class="form-label">Drop off</span>
<input class="form-control" type="date" required>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<span class="form-label">Pick up</span>
<input class="form-control" type="date" required>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-4">
<div class="form-group">
<span class="form-label">Pet?</span>
<select class="form-control">
<option>Cat</option>
<option>Dog</option>
<option>Others</option>
</select>
<span class="select-arrow"></span>
</div>
</div>
<div class="col-sm-4">
<div class="form-group">
<span class="form-label">Service</span>
<select class="form-control">
<option>Day Care</option>
<option>Boarding</option>
<option>Sitting</option>
</select>
<span class="select-arrow"></span>
</div>
</div>
</div>
<div class="form-btn">
<button class="submit-btn">Check availability</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
//about the white space try set the margin-top of the body at 0;
//about the the hamberger icon try this:
nav {
display:flex;
flex-direction: flex-end; }
To move the hamburger to the right side, make sure your #menuToggle position is fixed or absolute, then removeleft: 50px; and add right: 50px; and if you want more top space you can increase top attribute value, ex: top: 100px; or top: 0; if you don't want any top space.
I've commented the CSS bellow, in case you were wondering what i've changed.
Here is the CSS code you should use: (I've tested it and it's working for me)
#menuToggle {
display: block;
position: fixed;
top: 50px; /** NOTE: decrease The pixels if want less space */
right: 50px;/** NOTE: Change This line */
z-index: 1;
-webkit-user-select: none;
user-select: none;
}
#menuToggle a {
text-decoration: none;
color: #232323;
transition: color 0.3s ease;
}
#menuToggle a:hover {
color: tomato;
}
#menuToggle input {
display: block;
width: 40px;
height: 32px;
position: absolute;
top: -7px;
left: -5px;
cursor: pointer;
opacity: 0;
/* hide this */
z-index: 2;
/* and place it over the hamburger */
-webkit-touch-callout: none;
}
/*
* Just a quick hamburger
*/
#menuToggle span {
display: block;
width: 33px;
height: 4px;
margin-bottom: 5px;
position: relative;
background: #cdcdcd;
border-radius: 3px;
z-index: 1;
transform-origin: 4px 0px;
transition: transform 0.5s cubic-bezier(0.77, 0.2, 0.05, 1.0),
background 0.5s cubic-bezier(0.77, 0.2, 0.05, 1.0),
opacity 0.55s ease;
}
#menuToggle span:first-child {
transform-origin: 0% 0%;
}
#menuToggle span:nth-last-child(2) {
transform-origin: 0% 100%;
}
/*
* Transform all the slices of hamburger
* into a crossmark.
*/
#menuToggle input:checked~span {
opacity: 1;
transform: rotate(45deg) translate(-2px, -1px);
background: #ffffff;
}
/*
* But let's hide the middle one.
*/
#menuToggle input:checked~span:nth-last-child(3) {
opacity: 0;
transform: rotate(0deg) scale(0.2, 0.2);
}
/*
* Ohyeah and the last one should go the other direction
*/
#menuToggle input:checked~span:nth-last-child(2) {
transform: rotate(-45deg) translate(0, -1px);
}
/*
* Make this absolute positioned
* at the top left of the screen
*/
#menu {
position: absolute;
width: 300px;
margin: -100px 0 0;/** NOTE: Change this line */
padding: 50px;
padding-top: 125px;
right: -50px; /*NOTE: Add this line */
background: #ededed;
list-style-type: none;
-webkit-font-smoothing: antialiased;
/* to stop flickering of text in safari */
transform-origin: 0% 0%;
transform: translateX(100%);/** NOTE: Change this line */
transition: transform 0.5s cubic-bezier(0.77, 0.2, 0.05, 1.0);
}
#menu li {
padding: 10px 0;
font-size: 22px;
}
/*
* And let's slide it in from the left
*/
#menuToggle input:checked~ul {
transform: none;
}
/*----------------------------------menu----------------------------*/

How to properly centralize span inside a button?

I'm trying to give the look of a gradient border to a button by creating a span inside the button and setting some padding difference between them.
It works pretty well on codepen, but when I pass it to my website, something happens and these tags suddenly stop being aligned.
However, which is the best way to set a span centralized inside a button in order to simulate a border?
body{
background:white;
text-align:center;
box-sizing:border-box;
font-family:"Lato",Sans-serif;
padding-top:5%;
/* position:relative; */
}
.btn:link,
.btn:visited{
text-decoration: none;
text-transform:uppercase;
position:relative;
top:0;
left:0;
padding:22px 2px;
border-radius:100px;
display:inline-block;
transition: all .5s;
}
.btn-white{
background-image:linear-gradient(56deg, #08AEEA 0%, #2AF598 100%);
color:#000;
font-family: Lato;
font-size:1.3rem;
}
.btn span {
align-items: center;
background-color: #fff;
border-radius:100px;
display: absolute;
justify-content: center;
padding:20px 40px;
height: 100%;
transition: background .5s ease;
width: 100%;
}
.btn:hover span {
background: transparent;
}
.btn:hover{
background-image: linear-gradient(56deg, #08AEEA 0%, #2AF598 100%);
border: none;
box-shadow:0px 10px 10px rgba(0,0,0,0.2);
color: #fff;
transform : translateY(-3px);
}
.btn:active{
box-shadow:0px 5px 10px rgba(0,0,0,0.2)
transform:translateY(-1px);
}
.btn-bottom-animation-1{
animation:comeFromBottom 1s ease-out .8s;
}
.btn::after{
content:"";
text-decoration: none;
text-transform:uppercase;
position:absolute;
width:100%;
height:100%;
top:0;
left:0;
border-radius:100px;
display:inline-block;
z-index:-1;
transition: all .5s;
}
.btn-white::after {
background-image: linear-gradient(56deg, #08AEEA 0%, #2AF598 100%);
background-color: #fff;
}
.btn-animation-1:hover::after {
transform: scaleX(1.4) scaleY(1.6);
opacity: 0;
}
#keyframes comeFromBottom{
0%{
opacity:0;
transform:translateY(40px);
}
100%{
opacity:1;
transform:translateY(0);
}
}
<a class="btn" href="#">
<span>A brand new button!</span>
</a>
Well if it worked in Codepen and now doesn't its because your site is overriding something or you're not including the reset/normalize or vendor prefixing that Codepen is using by default.
Now you shouldn't need to do any "centering" to accomplish what I think you want.
Simply make the span a block level element and give it a margin or give the button padding.
button {
background-color: blue;
border: 2px solid darkBlue;
font-size: 14px;
padding: 4px;
}
button span {
display:block;
background: tan;
border:2px solid aqua;
padding: 10px 20px;
color: white;
}
<button>
<span>Text</span>
</button>
May be this is the solution that you intended to achieve. I have to edit a lot to your code to achieve that. Here is Codepen version
body {
background: white;
text-align: center;
box-sizing: border-box;
font-family: "Lato", Sans-serif;
padding-top: 5%;
/* position:relative; */
}
.btn:link,
.btn:visited {
text-decoration: none;
text-transform: uppercase;
/* position: relative; */
/* top: 0; */
/* left: 0; */
padding: 10px;
/* this padding will be your gradient border */
border-radius: 100px;
display: inline-block;
transition: all .5s;
border: none;
}
.btn:hover {
background-image: linear-gradient(56deg, #08AEEA 0%, #2AF598 100%);
/* border: none; */
box-shadow: 0px 10px 10px rgba(0, 0, 0, 0.2);
/* color: #fff; */
transform: translateY(-3px);
}
.btn span {
/* align-items: center; */
background-color: transparent;
/* background-color: #fff; */
border-radius: 100px;
/* display: absolute; */
/* justify-content: center; */
/* padding: 20px 40px; */
/* padding: 20px; */
/* height: 100%; */
/* transition: background .5s ease; */
transition: all .5s ease;
/* width: 100%; */
display: block;
padding: 20px 40px;
}
.btn:hover span {
/* background: transparent; */
background: #fff;
color: #ccc;
}
/* .btn-white {
background-image: linear-gradient(56deg, #08AEEA 0%, #2AF598 100%);
color: #000;
font-family: Lato;
font-size: 1.3rem;
} */
/*
.btn:active {
box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.2);
transform: translateY(-1px);
}
.btn-bottom-animation-1 {
animation: comeFromBottom 1s ease-out .8s;
} */
/* .btn::after {
content: "";
text-decoration: none;
text-transform: uppercase;
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
border-radius: 100px;
display: inline-block;
z-index: -1;
transition: all .5s;
} */
/*
.btn-white::after {
background-image: linear-gradient(56deg, #08AEEA 0%, #2AF598 100%);
background-color: #fff;
}
.btn-animation-1:hover::after {
transform: scaleX(1.4) scaleY(1.6);
opacity: 0;
}
#keyframes comeFromBottom {
0% {
opacity: 0;
transform: translateY(40px);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
*/
<a class="btn" href="#">
<span>A brand new button!</span>
</a>

How to hide tooltip?

I am using css to create tooltip, 4 tooltips are placed sequentially, 2nd tooltip appears on the popup content of 1st tooltip
The following code is placed in between jsp file in liferay, every jsp file has the tooltip code in it. If I open the 1st tooltip, other tooltips appear on the popup content of 1st tooltip,
I need to show the popup contents without any interruption. How do I do that?
My code is
.help-tip {
position: absolute;
top: 34px;
right: 120px;
text-align: center;
background-color: #a3c2c2;
border-radius: 50%;
width: 14px;
height: 10px;
font-size: 10px;
line-height: 16px;
cursor: default;
}
.help-tip:before {
content: '?';
font-weight: normal;
font-size: 10px;
color: #fff;
}
.help-tip:hover p {
display: block;
transform-origin: 100% 0%;
-webkit-animation: fadeIn 0.3s ease-in-out;
animation: fadeIn 0.3s ease-in-out;
}
.help-tip p {
/* The tooltip */
display: none;
text-align: center;
/*background-color: #a3c2c2;*/
padding: 5px;
width: 170px;
position: absolute;
border-radius: 6px;
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.4);
right: -100px;
/*color: #000000;*/
font-size: 14px;
line-height: 1.4;
color: #000000;
background: #FBF5E6;
background: -webkit-linear-gradient(top, #FBF5E6, #FFFFFF);
background: linear-gradient(top, #FBF5E6, #FFFFFF);
border: 1px solid #CFB57C;
}
.help-tip p:before {
/* The pointer of the tooltip */
position: absolute;
content: '';
width: 0;
height: 0;
border: 6px solid transparent;
border-bottom-color: #66ccff;
right: 100px;
top: -12px;
}
.help-tip p:after {
/* Prevents the tooltip from being hidden */
width: 100%;
height: 40px;
content: '';
position: absolute;
top: -40px;
left: 0;
}
/* CSS animation */
#-webkit-keyframes fadeIn {
0% {
opacity: 0;
transform: scale(0.6);
}
100% {
opacity: 100%;
transform: scale(1);
}
}
#keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 100%;
}
}
<div class="help-tip">
<p>This is the inline edit help tip!</p>
</div>
Due to using the exact same code for each tooltip, every tooltip will have the CSS property, position: absolute; and that could be causing the problem. Try changing all the positions to relative.