I would like a vertically aligned text to rotate in the horizontal direction when it is hovered. As an animation. Unfortunately I can't get any further at the moment. It is about the link on the right ("back"). Who knows how to do it? Thanks for advance!
.container {
display: block;
position: relative;
border: solid 3px #ccc;
padding: 40px 60px;
max-width: 400px;
margin: 100px auto 0;
}
#nav {
position: absolute;
top: 50px;
left: 20px;
}
#nav a {
writing-mode: vertical-rl;
text-orientation: mixed;
transform: rotate(180deg);
font-weight: bold;
color: var(--text-color)
}
#nav a {
writing-mode: vertical-rl;
text-orientation: mixed;
transform: rotate(180deg);
}
#nav a:hover {
writing-mode: vertical-rl;
text-orientation: mixed;
transform: rotate(180deg);
color: red;
}
<div id="nav">
back
</div>
<div class="container">123</div>
The display property has to be changed to block for the transform to work. You don’t need to change the direction when the transform works. You can set the transform to initial on :hover and set transition for the animation.
.container {
display: block;
position: relative;
border: solid 3px #ccc;
padding: 40px 60px;
max-width: 400px;
margin: 100px auto 0;
}
#nav {
position: absolute;
top: 50px;
left: 20px;
}
#nav a {
display: block;
transform: rotate(-90deg);
transition: .3s;
font-weight: bold;
color: var(--text-color)
}
#nav a:hover {
transform: initial;
color: red;
}
<div id="nav">
back
</div>
<div class="container">123</div>
Related
So I've got a problem where I've got two tabs (https://codepen.io/databell/pen/LYjxvyx) where the first tab opens up content and the second opens up a modal.
Now to be clear, those functions work. That's not the issue. So for those purposes, I deleted those out of my example. Focusing on CSS here.
My problem is I want plus + symbols to appear to the right side of each tab (really a div) and instead one tab has the symbol to the far right of the container, even though the tab is set to width 100%. So I'm stumped as to what the problem is.
This is meant to go into a Shopify store using the Dawn theme, so I'm using their elements here to create this interface.
Here's the code.
<div id="info-additions" class="product__accordion accordion info-additions-content" >
<details>
<summary>
<div class="summary__title info-additions-tab g-flex">
<h2 class="h4 accordion__title t-body benefits">
Tab One
<span></span>
</h2>
</div>
<div class="summary__title info-additions-tab g-flex">
<modal-opener class="product-popup-modal__opener no-js-hidden" data-modal="#PopupModal-ingr">
<button id="ProductPopup-ingr" class="summary__title t-body ingredients" type="button" aria-haspopup="dialog" data-additions-tab="ingredients">
<h2 class="h4 accordion__title">
Tab Two
<span></span>
</h2>
</button>
</modal-opener>
</div>
</summary>
<div class="accordion__content rte">
<p>Content</p>
</div>
</details>
</div>
CSS:
body {
font-size: 1.6rem;
}
*, ::before, ::after {
box-sizing: inherit;
}
.h0, .h1, .h2, .h3, .h4, .h5, h1, h2, h3, h4, h5 {
letter-spacing: .06rem;
line-height: 1.3;
}
.h4, h4 {
font-size: 1.6rem;
}
.grid {
list-style: none;
}
.g-flex {
display: flex;
display: -webkit-flex;
flex-wrap: wrap;
-webkit-flex-wrap: wrap;
}
.accordion summary {
cursor: pointer;
display: flex;
position: relative;
list-style: none;
line-height: 1;
padding: 1.5rem 0;
}
.accordion__title {
display: inline-block;
max-width: calc(100% - 6rem);
min-height: 1.6rem;
margin: 0;
word-break: break-word;
}
details > * {
box-sizing: border-box;
}
.accordion__title {
word-break: break-word;
}
.accordion .summary__title {
display: flex;
flex: 1;
}
#info-additions {
clear: both;
height: auto;
margin: 15px 0 0;
border-top: 2px solid;
border-bottom: 2px solid;
width: 100%;
}
.info-additions-content {
position: relative;
height: 0;
transition: .6s var(--a-cubic-1);
}
.info-additions-tab {
justify-content: space-between;
}
.info-additions-tab span {
display: block;
position: absolute;
width: 18px;
height: 18px;
top: 13px;
right: 2rem;
}
.info-additions-tab button {
position: relative;
padding: 16px 0!important;
line-height: 1;
font-weight: 500;
text-align: left;
}
.info-additions-tab button.benefits {
width: 50%;
}
.info-additions-tab .product-popup-modal__opener {
width: 100% !important;
}
.info-additions-tab button.ingredients {
width: 100%;
}
.info-additions-tab span {
display: block;
position: absolute;
width: 18px;
height: 18px;
top: 13px;
right: 2rem;
}
.info-additions-tab span:before,
.info-additions-tab span:after {
content: '';
display: block;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%) rotate(90deg);
transform: translate(-50%, -50%) rotate(90deg);
width: 2px;
height: 18px;
background-color: black;
transition: 0.3s;
}
.info-additions-tab button:not(.active) span:after {
-webkit-transform: translate(-50%, -50%) rotate(180deg);
transform: translate(-50%, -50%) rotate(180deg);
}
.info-additions-content {
position: relative;
height: 0;
transition: 0.6s var(--a-cubic-1);
}
.info-additions-content [data-additions-content] {
position: absolute;
width: 100%;
top: 0;
left: 0;
padding: 5px 0 20px;
opacity: 0;
pointer-events: none;
transition: 0.3s 0s;
}
.info-additions-content [data-additions-content].active {
opacity: 1;
pointer-events: auto;
transition-delay: 0.4s;
}
#info-additions button {
padding: 0;
background: transparent;
color: inherit;
cursor: pointer;
border: 0;
border-radius: 0;
outline: none;
-webkit-appearance: none;
-moz-appearance: none;
-o-appearance: none;
appearance: none;
transition: 0.2s;
}
if you want an absolute element like + to stay in the parent element you have to set the position of the parent to "relative".
you have two problems. summary__title doesn't have a position so + doesn't stay in it .
for the second tab, your modal button has a relative position that makes the + stay inside of it instead of the summary__title.
.accordion .summary__title {
...
position: relative; // add position
}
#info-additions button {
...
position: unset; // unset the position of the button
}
How do I make li elements not move around when applying transitions using :hover? The circles are made applying height and border-radius to the li elements. I've tried making the ul container bigger, but that didn't seem to work. Thanks for your help.
Code:
body {}
main {
display: flex;
background: #eeeeee;
min-height: 100vh;
padding: 1em;
}
h1 {
font-family: arial;
font-size: 1.4em;
padding-left: 1em;
}
ul {
padding-top:50px;
min-height: 600px;
position:relative;
}
li {
position:relative;
background-color: purple;
border-radius: 50%;
width: 50px;
height: 50px;
padding: 1em;
text-align: center;
list-style: none;
display: inline-block;
line-height: 50px;
border: 5px solid red;
margin-right: -1em;
z-index: 0;
transition: width 0.5s, height 0.5s, background-color 1s, line-height 0.5s;
}
li:hover {
display: inline-block;
position:relative;
width: 90px;
height: 90px;
z-index: 10;
background-color: green;
line-height: 90px;
}
<body>
<main>
<h1>
My animated Menu
</h1>
<div class="menu">
<ul>
<li>X</li>
<li>Y</li>
<li>Z</li>
</ul>
</div>
</main>
</body>
Use CSS3 transforms, this way the element can freely move or scale into the DOM without affecting the layout size.
A nice bonus: the animation will be more efficient in terms of fps as the layout won't be re-computed on each frame (an the GPU will be used)
ul {
padding-top: 50px;
}
li {
background-color: purple;
border-radius: 50%;
width: 50px;
height: 50px;
padding: 1em;
text-align: center;
list-style: none;
display: inline-block;
line-height: 50px;
border: 5px solid red;
margin-right: -1em;
z-index: 0;
transition: transform 0.5s, background-color 1s;
}
li:hover {
display: inline-block;
position: relative;
transform: scale(1.5);
z-index: 10;
background-color: green;
}
<div class="menu">
<ul>
<li>X</li>
<li>Y</li>
<li>Z</li>
</ul>
</div>
I'm having trouble making a div button responsive in a webpage. I have changed all pixel values to percentages and the problem still exists.
.wrapper {
display: block;
position: absolute;
left: 30%;
transform: translate(-50%, -50%);
}
.testing {
padding: 10% 10%;
text-align: center;
text-decoration: none;
color: #ffffff;
background-color: #009ac9;
border: 2px solid transparent;
font-size: 90%;
display: inline-block;
border-radius: 0.1em;
transition: all 0.2s ease-in-out;
position: relative;
overflow: hidden;
}
.testing:hover {
background-color: #ffffff;
color: #009ac9;
border-color: #009ac9;
}
<div class="wrapper">
LOG IN
</div>
Another problem is, I have a fullscreen overlay menu and I'd like to disable this button when the overlay is present. As of now, the button is still clickable when the overlay is present. I'd like to disable it:
Image
Try this, I think this will be helpful.
.wrapper {
display: block;
position: absolute;
left: 0;
top: 0;
right:0;
bottom:0;
z-index:9;
}
.testing {
padding: 10% 10%;
text-align: center;
text-decoration: none;
color: #ffffff;
background-color: #009ac9;
border: 2px solid transparent;
font-size: 15px;
display: inline-block;
border-radius: 0.1em;
transition: all 0.2s ease-in-out;
position: relative;
overflow: hidden;
position:relative;
left:50%;
top:50%;
width:20%;
min-width:50px;
transform: translate(-50%, -50%);
}
.testing:hover {
background-color: #ffffff;
color: #009ac9;
border-color: #009ac9;
}
<div class="wrapper">
LOG IN
</div>
And for the menu give z-index:999; to the .overlay in your Fullscreen Overlay menu style.I think it will work for you.
Try vh in place of percentages, Hope it will Work and use media query also in responsive screen.
https://www.w3schools.com/css/tryit.asp?filename=tryresponsive_mediaquery
Here you can see my issue. I assume it has to do with the block and inline-block. I want to cleanly make the text appear when hovering over the area. Preferably all in CSS. If anyone can point me in the right direction, that'd be amazing. Thank you!
HTML
<div class="contact-icon icongrow" id="github">
<span class="fa fa-github icon"></span>
<span class="contact-icon-text">#username</span>
</div>
CSS
#github {
border-radius: 15px 10px;
padding: 8px 5px 5px 8px;
background: #000000;
color: #FFFFFF;
}
.icon {
float:none;
}
.icongrow {
font-size:24px;
width: 24px;
transition:width 1s;
display: block;
}
.icongrow:hover {
font-size: 28px;
width: 300px;
}
.icongrow:hover .contact-icon-text {
display: inline-block;
}
.contact-icon-text {
display: none;
}
https://jsfiddle.net/sfpfka64/
Add white-space: nowrap to .icongrow
.icongrow {
font-size:24px;
width: 24px;
transition:width 1s;
display: block;
white-space: nowrap;
}
and add an opacity transition to contact-icon-text :
.icongrow:hover .contact-icon-text {
opacity: 1;
}
.contact-icon-text {
opacity: 0;
display:inline-block;
transition: all 0.5s;
}
Also make the font-size on hover same as the initial font-size to provide more smoothness :
.icongrow:hover {
font-size: 24px;
width: 300px;
}
Snippet
#github {
border-radius: 15px 10px;
padding: 8px 5px 5px 8px;
background: #000000;
color: #FFFFFF;
}
.icon {
float:none;
}
.icongrow {
font-size:24px;
width: 24px;
transition:width 1s;
display: block;
white-space: nowrap;
}
.icongrow:hover {
font-size: 24px;
width: 300px;
}
.icongrow:hover .contact-icon-text {
opacity: 1;
}
.contact-icon-text {
opacity: 0;
display:inline-block;
transition: all 0.5s;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="contact-icon-container">
<div class="contact-icon icongrow" id="github">
<span class="fa fa-github icon"></span>
<span class="contact-icon-text">#username</span>
</div>
</div>
Just add the following rules to the .icongrow
white-space: nowrap;
overflow: hidden;
Working fiddle: https://jsfiddle.net/yvqga0ja/
An easy way would be to put your "contact-icon-text" as a position absolute, so that he would always be placed at the right place.
Demo
.contact-icon-container{
position:relative;
}
.contact-icon-text {
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 10px;
opacity: 0;
}
.icongrow:hover .contact-icon-text {
opacity: 1;
transition: .3s ease-in;
You can add transition-delay in order to make your text appear a bit later, but you get the way I would do it :)
I am working on a <nav> for a mobile site. It is working file in Firefox and Chrome but not in Safari. I am running it on Windows 8.1 and I observed the same issue on Safari in iPad mini.
In the snippet below, if you check out the mobile view (max-width: 768px) and click on the menu icon in the top right corner, that icon is suppose to animate to a cross (X) icon, also the nav menu is suppose to slide down.
$("a.nav-opener").click(function(e) {
e.preventDefault();
$('body').toggleClass("nav-active");
});
#media screen and (max-width: 768px){
.holder {
padding: 14px;
}
.logo {
float: none;
display: block;
margin: 0px auto;
width: 168px;
position: relative;
z-index: 2;
}
a {
text-decoration: none;
color: #DC7952;
outline: medium none;
}
.logo img {
width: 100%;
height: auto;
display: block;
}
img {
max-width: 100%;
height: auto;
}
.nav-opener {
display: block;
position: absolute;
top: 0px;
right: 0px;
border-left: 1px solid #D4D4D4;
width: 65px;
height: 53px;
text-indent: -9999px;
overflow: hidden;
background: none repeat scroll 0% 0% transparent;
z-index: 15;
}
.nav-opener::before, .nav-opener::after {
content: "";
top: 19px;
}
.nav-opener::before, .nav-opener::after, .nav-opener span {
background: none repeat scroll 0% 0% #DC7952;
position: absolute;
left: 15%;
right: 15%;
height: 6px;
margin-top: -2px;
transition: all 0.2s linear 0s;
}
.nav-opener::after {
top: 37px;
}
.nav-opener span {
background: none repeat scroll 0% 0% #DC7952;
position: absolute;
top: 28px;
left: 15%;
right: 15%;
height: 6px;
margin-top: -2px;
transition: all 0.2s linear 0s;
}
.nav-active .nav-opener::after, .nav-active .nav-opener::before {
transform: rotate(45deg);
border-radius: 3px;
top: 24px;
left: 15%;
right: 15%;
}
.nav-active .nav-opener::after {
transform: rotate(-45deg);
}
.nav-opener::before, .nav-opener::after {
content: "";
}
.nav-active .nav-opener span {
display: none;
}
.navigation-container {
border: 0px none;
overflow: hidden;
position: absolute;
top: 53px;
left: 0px;
right: 0px;
z-index: 999;
max-height: 0px;
transition: all 0.25s linear 0s;
margin: 0px;
padding: 0px;
}
.nav-active .navigation-container {
max-height: 4000px;
}
.navigation-container .drop {
transition: all 0.25s linear 0s;
transform: translateY(-100%);
background: none repeat scroll 0% 0% #FFF;
width: 100%;
display: table;
}
.nav-active .drop {
transform: translateY(0px);
}
#nav {
margin: 0px;
overflow: visible;
font-size: 24px;
display: table-header-group;
font-family: "apercu",sans-serif;
font-weight: 700;
line-height: 1.4285;
text-transform: uppercase;
}
#nav ul {
display: block;
border-top: 1px solid #E8E8E8;
padding: 0px;
width: 100%;
margin: 0px;
}
#nav li {
display: block;
width: auto;
border-style: solid;
border-color: #E8E8E8;
-moz-border-top-colors: none;
-moz-border-right-colors: none;
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
border-image: none;
border-width: 0px 0px 1px;
list-style: outside none none;
}
#nav li.active a, #nav li a:hover {
text-decoration: none;
color: #FFF;
background: none repeat scroll 0% 0% #DC7952;
}
#nav a {
display: block;
text-align: left;
padding: 15px 20px;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="holder">
<strong class="logo">Some logo</strong>
</div>
<!-- navigation opener -->
<span>opener</span>
<div class="navigation-container">
<div class="drop">
<!-- main navigation of the page -->
<nav id="nav">
<ul>
<li class="active">HOME</li>
<li>BIBLE RESOURCES</li>
<li>OUR MISSION</li>
</ul>
</nav>
</div>
</div>
Equivalent jsFiddle
Can anyone point me in the right direction?
Transform and transition don't work on safari and chrome without browser perfix that is webkit for safari so use:
-webkit-transform and -webkit-transition instead...
the transform property need to be prefixed in safari
for ex.: -webkit-transform
for any other resource check this
Apple stopped releasing Safari latest versions for windows long back (2012). Might be your using old Safari browser which is not compatible with CSS3..
Chrome and latest safari works on webkit rendering engine.. If it works in chrome then it will work same on safari as well.
Safari Versions which support transform:
http://caniuse.com/#feat=transforms2d
Correct me if i'm wrong :)
As mentioned in http://html-tuts.com/fix-laggy-transitions-in-css/ you also need to add an extra property when you work with Safari and transition, or else it can get laggy.
You do this by adding the css property transform with the value translateZ(0) to the element with the transition property - in this case:
.nav-opener span {
...
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
-o-transform: translateZ(0);
transform: translateZ(0);
}