When I hover the p tag and add a letter-spacing on it, it messes up the entire text. I wanted to hover it and it stays in the same position with the letter-spacing on it.
#text {
position: absolute;
transform: translate(-50%, -50%);
left: 40%;
top: 50%;
font-size: 2em;
transform: rotate(90deg);
}
#text:hover {
letter-spacing: 10px
}
<p id="text">sample text rotation</p>
Just add white-space: nowrap
BTW, your second transform rewrites the first one.
The correct use is transform: translate(-50%, -50%) rotate(90deg);
#text {
position: absolute;
transform: translate(-50%, -50%) rotate(90deg);
left: 40%;
top: 50%;
font-size: 2em;
white-space: nowrap;
}
#text:hover {
letter-spacing: 10px
}
<p id="text">sample text rotation</p>
The flickering happens because the transform-origin is wrong. You're rotating the text, so you should take the original transform-origin into account (which is from left to right).
See this updated code snippet for the result.
.text {
position: absolute;
transform-origin: top left;
left: 70%;
top: 20%;
font-size: 2em;
transform: rotate(90deg);
}
.text:hover {
letter-spacing: 10px;
}
<p class="text">sample text rotation</p>
Couple of things:
You have 2 transform tags on your css
You still will need more spacing padding so the hover is not flickering
Also Im sure you wanted a transition so try this:
#text {
transition: letter-spacing 0.5s;
}
#text {
display: block;
padding: 0;
position: absolute;
left: 40%;
top: 50%;
font-size: 2em;
transform: translate(-50%, -50%) rotate(90deg);
transition: letter-spacing 0.5s;
}
#text:hover {
letter-spacing: 10px
}
<p id="text">sample text rotation</p>
You will probably need more block /width /spacing so it can get the right setup but thats all you...
Related
I am trying to horizontally center align a inline-block element that also has a fixed position. This is because this element is also being animation via transform translation. Current attempt looks like this:
.cd-nav-trigger {
position: fixed;
display: inline-block;
}
.cd-nav-trigger {
bottom: 7%;
left: 48.25%;
top: auto;
right: auto;
width: 44px;
height: 44px;
z-index: 5;
/* image replacement */
overflow: hidden;
text-indent: 100%;
white-space: nowrap;
}
.cd-overlay-nav, .cd-overlay-content {
/* containers of the 2 main rounded backgrounds - these containers are used to position the rounded bgs behind the menu icon */
position: fixed;
bottom: 7%;
left: 48.25%;
height: 4px;
width: 4px;
-webkit-transform: translateX(20px) translateY(-20px);
-moz-transform: translateX(20px) translateY(-20px);
-ms-transform: translateX(20px) translateY(-20px);
-o-transform: translateX(20px) translateY(-20px);
transform: translateX(20px) translateY(-20px);
}
HTML implementation is this:
</div> <!-- cd-overlay-content -->
Menu<span class="cd-icon"></span>
</div>
The left property is not allowing me to correctly align the element, even when set to 50%. Any help would be appreciated.
Try to add a negative margin-left (half of the width)
.cd-nav-trigger {
position: fixed;
bottom: 7%;
left: 50%;
width: 44px;
height: 44px;
margin-left: -22px;
}
Menu<span class="cd-icon"></span>
Hello
I have this web site www.acigaiabeta.esy.es, that im trying to align the images of the carousel to the center vertically, but it´s always stuck to the top.
I even tryed to folow this tip How to vertically align an image inside div, but still didnt change place.
On big images theres is no big deal, but with small images there is a problem, and the images sizes are random.
what am i missing?
.carousel .item {
vertical-align: middle;
height: 500px;
background-color: #777;
}
.carousel-inner > .item > img {
vertical-align: middle;
max-width: 100%;
height: auto;
margin: auto;
top:auto;
-webkit-transition: 0.6s ease-in-out left;
-moz-transition: 0.6s ease-in-out left;
-o-transition: 0.6s ease-in-out left;
transition: 0.6s ease-in-out left;
}
Im only trying by css i tryed using the top, the vertical-align: middle like on the like showed above nothing works.
Here's the CSS you need:
#myCarousel img {
position: absolute;
max-width: 100%;
max-height: 100%;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
-o-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
Try it.
.first-slide {
position: abolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
margin: auto;
}
I have a couple sets of layers that are all set to position: absolute; and they display over each other. I have delays and fadeOut's in place so it acts in sequence. For some reason on my last display layer, if I set the z-index to a number that is displays, it effects all of the others, even though it is not showing. There will just be a blank section with my background-color, sort of like a block.
Here is the code for it. The div in question is home-learn. I have tried changing the z-index to be above the other layers, equal and less than equal. Each different way causes its own separate issue.
For example, right now I have it set to 1 z-index number less than the layer over top of that. Doing this causes it not to show, but if I make it equal or more, the background-color will go over-top of blue-home-text in the size of the wording for home-learn.
Does anyone see what I am doing wrong? To see this live may help. In a comment below, I will add the live site. You will see it right on page load, after the sequence completes.
<div class="red">
<div id="hand-wrap"><img src="/images/hand.png" class="hand" alt="HELLO"></div>
<span class="hand-text">HELLO</span>
<div class="circle">
<div class="spinner top topright"></div>
<div class="spinner top topleft"></div>
<div class="spinner bottom bottomleft"></div>
<div class="spinner bottom bottomright"></div>
<div class="mask q2"></div>
<div class="mask q4"></div>
</div>
<div id="circle-text">We're Optimum
<br>Designs</div>
<div id="blue-home-text">We build beautiful, engaging sites for companies both large and small.</div>
<!-- <div id="text-button"><span class="border-span">More About Us</span></div> -->
<div id="home-learn">
<div id="curtain-div"></div>
Learn more...
</div>
</div>
.red {
background-color: #0085A1;
width: 100%;
height: 100vh;
position: relative;
text-align: center;
}
.hand {
width: auto;
height: auto;
position: absolute;
z-index: 100;
-webkit-transform: translate(-50%, -50%) rotate(0deg);
transform: translate(-50%, -50%) rotate(0deg);
top: 60%;
left: 50%;
-webkit-animation: wave 4s 1 normal forwards;
animation: wave 4s 1 normal forwards;
}
.hand-text {
position: absolute;
text-align: center;
left: 0;
right: 0;
top: 42%;
color: #FFF;
font-size: 2em;
font-weight: bold;
opacity: 0;
-webkit-animation: waveTxt 2s 0s 2 alternate;
animation: waveTxt 2s 0s 2 alternate;
}
.circle {
display: none;
z-index: 99;
width: 500px;
height: 500px;
position: absolute;
background: inherit;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%) rotate(0deg);
transform: translate(-50%, -50%) rotate(0deg);
}
.spinner {
width: 250px;
height: 250px;
position: absolute;
border: 5px solid #b5f2ff;
z-index: 10;
}
#circle-text {
display: none;
position: absolute;
color: #FFF;
font-size: 2.3em;
text-align: center;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
z-index: 100;
}
#blue-home-text {
color: #FFF;
display: none;
text-align: center;
position: absolute;
margin: 0 25%;
top: 50%;
font-size: 2.3em;
z-index: 99;
}
#home-learn {
color: #FFF;
position: absolute;
text-align: center;
/*margin: 0 25%;*/
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
font-size: 2.3em;
z-index: 98;
}
After reviewing your code I believe the following CSS should help with the laying issue. This should avoid the curtain layer from showing on top of the blue-home-text.
#home-learn {
z-index: 99;
}
#blue-home-text {
z-index: 100;
}
When I hover over the div, the .note span fades in. After it fades in, the font-weight seems to suddenly increase (it becomes bolder). I realize that in the fiddle there is no image, but it is not required to see my issue.
Html:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="script.js"></script>
<title>Cool Effect</title>
</head>
<body>
<div class="imageHolder">
<img src="picture1.jpeg">
<span class="note">Hello!</span>
</div>
</body>
</html>
CSS:
.imageHolder {
position: relative;
top:300px;
left: 300px;
width: 300px;
height: 250px;
text-align: center;
overflow: hidden;
background-color: black;
}
.note {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
border: 2px solid white;
padding: 8px;
color: white;
font-size: 24px;
opacity: 0;
-webkit-transition: opacity 0.5s;
transition: opacity 0.5s;
}
img {
width: 300;
opacity: 1;
height: 250px;
}
.imageHolder:hover .note {
opacity: 1;
}
Thanks.
Using a 3d transform (ie. using hardware acceleration) fixes lots of these rendering issues.
.note {
...
-webkit-transform: translate3d(-50%, -50%, 0);
transform: translate3d(-50%, -50%, 0);
...
}
This is well documented
DEMO
Alternatively, this also seems to work for your example and may have better browser support...
.note {
...
-webkit-backface-visibility: hidden;
...
}
DEMO
Note these changes:
.note {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
border: 2px solid white;
padding: 8px;
color: white;
font-size: 24px;
opacity: 0;
-webkit-transition: opacity 0.1s; <--
transition: opacity 0.1s; <--
}
Although the transition speed is slightly quicker this fixes the problem in the fiddle.
I have this side-pane. It's height is 80%. In this side-pane I have a text. I want this to always be in the middle.
Main div:
.simulation {
height: 80%;
width: 500px;
border: 1px solid #ccc;
box-shadow: 8px 8px 7px #A5A5A5;
background: #FFF;
position: absolute;
top: 10px;
z-index: 100;
left: -450px;
transition: 500ms ease all;
}
Sub div:
.simulation .simulation-content .simulation-bar .heading {
position: relative;
margin-top: 340px; /* How do I get this in the middle?? */
-webkit-transform: rotate(-90deg);
}
I can't get the margin-top right when i express it in %.
Plunkr: http://plnkr.co/edit/Z8xZNYLNvShQDVPZMZgk?p=preview
You could align the child element vertically at the middle of the parent by positioning the child absolutely and a combination of top: 50% and transform: translateY(-50%).
In this particular instance — Example:
.simulation .simulation-content .simulation-bar .heading {
position: absolute;
top: 50%;
left: 0;
-webkit-transform: translate(-30%, -50%) rotate(-90deg);
-moz-transform: translate(-30%, -50%) rotate(-90deg);
-ms-transform: translate(-30%, -50%) rotate(-90deg);
-o-transform: translate(-30%, -50%) rotate(-90deg);
transform: translate(-30%, -50%) rotate(-90deg);
}
An explanation can be found here:
How to center a "position: absolute" element
You can use also flexboxes to achieve it. just add:
display: flex;
flex-flow: column nowrap;
justify-content: center;
to your "main-content"