I have a responsive text box with a label that shifts up on a focus and if text box has input. I am trying to add an image to the right side of the text box that is aligned middle with the text box input. But the image is shifted down.
HTML:
<div style="margin-top: 20px">
<input class="responsiveTextBox" type="text" id="clientName" required="required" />
<img src="https://s31.postimg.org/6bym9bjnf/reset.png" class="resetImage">
<label class="responsiveLabel" id="lblClientName" for="clientName">Client Name</label>
<div class="bar"></div>
</div>
CSS:
.responsiveTextBox{
outline: none;
z-index: 1;
position: relative;
background: none;
width: 100%;
height: 60px;
border: 0;
color: black;
font-size: 16px;
font-weight: 400;
}
.responsiveLabel {
position: absolute;
top: 0;
left: 0;
color: #757575;
font-size: 20px;
font-weight: 300;
line-height: 60px;
-webkit-transition: 0.2s ease;
transition: 0.2s ease;
}
.responsiveTextBox:focus ~ label {
color: #9d9d9d;
-webkit-transform: translate(-12%, -50%) scale(0.75);
transform: translate(-12%, -50%) scale(0.75);
}
.responsiveTextBox.hasValue ~ label {
color: #9d9d9d;
-webkit-transform: translate(-12%, -50%) scale(0.75);
transform: translate(-12%, -50%) scale(0.75);
}
.responsiveTextBox:valid ~label {
color: #9d9d9d;
-webkit-transform: translate(-12%, -50%) scale(0.75);
transform: translate(-12%, -50%) scale(0.75);
}
.bar{
position: absolute;
left: 0;
/*bottom: 0;*/
background: #757575;
width: 100%;
height: 1px;
}
.resetImage{
float: right;
vertical-align: middle;
}
JSFIDDLE
Any suggestion how to resolve this issue?
Your input width is 100%, you need to reduce it and remove the float property from the img for vertical-align: middle to works
.responsiveTextBox{
width: 95%;
}
.resetImage {
vertical-align: middle;
}
Fiddle
Related
This question already has answers here:
Is there a CSS parent selector?
(33 answers)
Closed 7 months ago.
I have a navigation bar and a background (class="modal") which are set to
display: none;
How do I make it
display: block;
when the input checkbox menu-check is checked using only CSS.
[I have only shown the class modal since both navigation and modal classes act similarly]
.modal {
display: none;
position: absolute;
height: 100%;
top: 0;
left: 0;
right: 0;
background: #00827f;
}
.menu-btn {
position: fixed;
display: flex;
flex-direction: column;
gap: 5px;
bottom: 20px;
right: 20px;
padding: 15px;
border-radius: 20px;
z-index: 10;
background-color: #08ccc9;
cursor: pointer;
}
.menu-btn:hover>span:nth-of-type(1) {
transform-origin: right;
transform: scaleX(0.5);
}
.menu-btn:hover>span:nth-of-type(3) {
transform-origin: left;
transform: scaleX(0.5);
}
.menu-btn input {
display: none;
}
.menu-btn span {
width: 25px;
height: 4px;
border-radius: 999px;
background-color: black;
transition: all 0.3s ease;
}
.menu-btn input:checked~span:nth-of-type(1) {
transform: rotate(45deg) translate(5px, 7px);
transform-origin: center;
transition: all 0.3s ease, transform-origin 0s;
}
.menu-btn input:checked~span:nth-of-type(2) {
transform: translate(30px, 0px);
opacity: 0;
}
.menu-btn input:checked~span:nth-of-type(3) {
transform: rotate(-45deg) translate(5px, -7px);
transform-origin: center;
transition: all 0.3s ease, transform-origin 0s;
}
<label for="menu-check" class="menu-btn">
<input type="checkbox" id="menu-check">
<span></span>
<span></span>
<span></span>
</label>
<div class="modal"></div>
You need to change your HTML so that the checkbox is at the same level in the DOM as the modal. You can only select subsequent or child elements, not previous or ancestral elements.
#menu-check {display:none;}
.modal {
display: none;
position: absolute;
height: 100%;
top: 0;
left: 0;
right: 0;
background: #00827f;
}
.menu-btn {
position: fixed;
display: flex;
flex-direction: column;
gap: 5px;
bottom: 20px;
right: 20px;
padding: 15px;
border-radius: 20px;
z-index: 10;
background-color: #08ccc9;
cursor: pointer;
}
.menu-btn:hover>span:nth-of-type(1) {
transform-origin: right;
transform: scaleX(0.5);
}
.menu-btn:hover>span:nth-of-type(3) {
transform-origin: left;
transform: scaleX(0.5);
}
.menu-btn span {
width: 25px;
height: 4px;
border-radius: 999px;
background-color: black;
transition: all 0.3s ease;
}
/*Check Box CSS Manipulation*/
#menu-check:checked ~ .modal{
display:block;
}
#menu-check:checked ~ .menu-btn span:nth-of-type(1) {
transform: rotate(45deg) translate(5px, 7px);
transform-origin: center;
transition: all 0.3s ease, transform-origin 0s;
}
#menu-check:checked ~ .menu-btn span:nth-of-type(2) {
transform: translate(30px, 0px);
opacity: 0;
}
#menu-check:checked ~ .menu-btn span:nth-of-type(3) {
transform: rotate(-45deg) translate(5px, -7px);
transform-origin: center;
transition: all 0.3s ease, transform-origin 0s;
}
<input type="checkbox" id="menu-check">
<label for="menu-check" class="menu-btn">
<span></span>
<span></span>
<span></span>
</label>
<div class="modal"></div>
I'm trying to do some animation in a div with css rotate() but apparently it only works when I check the label, when I check again just show standard display.
Will be a bonus if someone help me to position the div that I use #rotator before, after vertical, this way they show 45º to a div.
Example: https://codepen.io/rafaart/pen/dyNjgeb
.ativar-dark{
width: 50px;
height: 50px;
display: none;
}
#sky {
background-color: black;
position: absolute;
overflow: hidden;
}
#rotator {
position: relative;
width: 7rem;
height: 7rem;
transform: rotate(-45);
border-radius: 50%;
border: 2px solid red;
margin: 3rem;
}
label{
cursor: pointer;
}
#rotator:before, #rotator:after {
position: absolute;
content: '';
display: block;
height: 3rem;
width: 3rem;
border-radius: 50%;
animation: inherit;
animation-direction: reverse;
}
#rotator:before {
background-color: yellow;
top: -.25rem;
left: -.25rem;
}
#rotator:after {
background-color: White;
bottom: -.25rem;
right: -.25rem;
}
.ativar-dark:checked ~ .container div{
transform: rotate(180deg);
-o-transform: rotate(180deg);
-ms-transform: rotate(180deg);
-webkit-transform: rotate(180deg);
transition: all ease 2s;
}
<input type="checkbox" id="ativar-dark" class="ativar-dark">
<div class="container" id="sky">
<label for="ativar-dark">
<div id="rotator">
</div>
</label>
</div>
I have made few tweaks to the code. Kindly check whether it satisfies your requirement.
Your input type contains the id and class of the same name. You mentioned .ativar-dark in the CSS but when I changed it to #ativar-dark it was working fine which is bit strange because id and class can have the same name.
.ativar-dark{
width: 50px;
height: 50px;
display: none;
}
#sky {
background-color: black;
position: absolute;
overflow: hidden;
}
#rotator {
position: relative;
width: 7rem;
height: 7rem;
border-radius: 50%;
border: 2px solid red;
margin: 3rem;
transform: rotate(0deg); /*enter 0 deg in order to return back to the original position when unchecked */
transition: all ease 2s; /* This will make sure it provides the animated effect when unchecked */
}
label{
cursor: pointer;
}
#rotator:before, #rotator:after {
position: absolute;
content: '';
display: block;
height: 3rem;
width: 3rem;
border-radius: 50%;
animation: inherit;
animation-direction: reverse;
}
#rotator:before {
background-color: yellow;
top: 2rem; /* Move the position of circle to center position */
left: -1.25rem;
}
#rotator:after {
background-color: White;
bottom: 2rem; /* Move the position of circle to center position */
right: -1.25rem;
}
#ativar-dark:checked ~ .container div{
transform: rotate(180deg);
-o-transform: rotate(180deg);
-ms-transform: rotate(180deg);
-webkit-transform: rotate(180deg);
transition: all ease 2s;
}
<input type="checkbox" id="ativar-dark" class="ativar-dark">
<div class="container" id="sky">
<label for="ativar-dark">
<div id="rotator">
</div>
</label>
</div>
You can toggle two classes using javascript to achieve the rotation on the click of the rotation element. Start with one present in the HTML element, then toggle them on click.
let circle = document.getElementById('rotator')
circle.addEventListener('click', function(e) {
e.target.classList.toggle('rotate')
e.target.classList.toggle('reverse')
})
.ativar-dark {
width: 50px;
height: 50px;
display: none;
}
#sky {
background-color: black;
position: absolute;
overflow: hidden;
}
#rotator {
position: relative;
width: 7rem;
height: 7rem;
transform: rotate(-45);
border-radius: 50%;
border: 2px solid red;
margin: 3rem;
}
label {
cursor: pointer;
}
#rotator:before,
#rotator:after {
position: absolute;
content: '';
display: block;
height: 3rem;
width: 3rem;
border-radius: 50%;
animation: inherit;
animation-direction: reverse;
}
#rotator:before {
background-color: yellow;
top: -.25rem;
left: -.25rem;
}
#rotator:after {
background-color: White;
bottom: -.25rem;
right: -.25rem;
}
.rotate {
transform: rotate(180deg);
-o-transform: rotate(180deg);
-ms-transform: rotate(180deg);
-webkit-transform: rotate(180deg);
transition: all ease 2s;
}
.reverse {
transform: rotate(0deg);
-o-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
transition: all ease 2s;
}
<input type="checkbox" id="ativar-dark" class="ativar-dark">
<div class="container" id="sky">
<label for="ativar-dark">
<div id="rotator" class="reverse">
</div>
</label>
</div>
I'm having a problem with html5 and css3, something is happening as a bug when I do hover in the image. Was for him to appear as the first 2 but does not appear only appears quickly in the hover in the image and already algune would know to tell me why this? Below the first image and the system running normally and the second image and the hover in the image.
my code HTML5:
<div class="col-lg-12" id="container">
<div class="ala col-lg-3 col-md-4 col-sm-6 col-xs-12 col-md-25">
<span style="position: absolute;top: -25px;font-size:1rem;margin-left: -30px;color:#666;left: 50%;font-family:'Lato', sans-serif;display:block" class="rate"> <input type="checkbox" name="star[]" class="star" value="1" id="star_1" checked>Favorita</span>
<div class="hovereffect clic">
<div class="clic" style="display:block"></div>
<div class="heart"></div>
<img class="img-responsive" src="../images/photo/namePhoto.jpg" alt="namePhoto">
<div class="overlay">
<a class="info test-popup-link" href="../images/photo/namePhoto.jpg"><img src="../images/lupa.png"></a><br><br><br>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary check active">
<input type="checkbox" class="ck" name="ck[]" checked value="1" id="ck_1"> <span class="che">Desmarcar</span>
</label>
</div>
</div>
</div>
</div>
My highlighted elements CSS code:
.hovereffect .clic {
background-color: #13B8DC;
z-index: 1;
overflow: hidden;
width: 80px;
height: 80px;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 0 100%;
-moz-transform-origin: 0 100%;
-ms-transform-origin: 0 100%;
-o-transform-origin: 0 100%;
transform-origin: 0 100%;
position: absolute;
top: -30px;
}
.clic:before {
content: "\f00c";
font: normal normal normal 14px/1 FontAwesome;
position: absolute;
top: 9px;
color: #fff;
z-index: 2;
font-size: 1rem;
left: 4px;
}
.hovereffect .heart {
width: 80px;
height: 80px;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 0 100%;
-moz-transform-origin: 0 100%;
-ms-transform-origin: 0 100%;
-o-transform-origin: 0 100%;
transform-origin: 0 100%;
position: absolute;
right: -80px;
top: -25px;
}
.heart {
background-color: #f36a5a;
z-index: 1;
}
.heart:before {
content: "\f004";
font: normal normal normal 14px/1 FontAwesome;
position: absolute;
top: 31px;
color: #fff;
z-index: 2;
font-size: 1.1rem;
left: 4px;
-webkit-transform: rotate(90deg);
-moz-transform: rotate(90deg);
-ms-transform: rotate(90deg);
-o-transform: rotate(90deg);
transform: rotate(90deg);
}
.ala{
width: 100%;
break-before: avoid;
break-after: avoid;
break-inside: avoid;
margin-top: 30px;
}
#container{
column-count: 5;
column-gap: 0;
}
These are the codes that appear both in the first image and in the second, but that do not appear in the rest of the images, could someone tell me what I can do to correct this error?
this demo:
https://jsfiddle.net/h69atvrc/
-> please attachment fontawesome library and link css in html
-> also set image path
.ala {
margin-top: 30px;
}
.clic::before {
color: #ffffff;
content: '\f00c';
font-family: 'FontAwesome';
font-size: 14px;
left: 4px;
position: absolute;
top: 9px;
z-index: 2;
}
.clic {
border-color: #13b8dc;
}
.hovereffect {
cursor: default;
float: left;
height: 100%;
overflow: hidden;
position: relative;
text-align: center;
width: 100%;
}
.hovereffect .clic {
background-color: #13b8dc;
height: 80px;
overflow: hidden;
position: absolute;
top: -30px;
transform: rotate(-45deg);
transform-origin: 0 100% 0;
width: 80px;
z-index: 1;
}
.hovereffect .heart {
height: 80px;
position: absolute;
right: -80px;
top: -25px;
transform: rotate(-45deg);
transform-origin: 0 100% 0;
width: 80px;
}
.heart {
background-color: #f36a5a;
z-index: 1;
}
.hovereffect img {
display: block;
position: relative;
transition: all 0.2s linear 0s;
}
.hovereffect .overlay {
background-color: rgba(0, 0, 0, 0.5);
height: 100%;
left: 0;
opacity: 0;
overflow: hidden;
position: absolute;
top: 0;
transition: all 0.2s ease-in-out 0s;
width: 100%;
}
.heart::before {
color: #ffffff;
content: '\f004';
font-family: 'FontAwesome';
font-size: 14px;
left: 4px;
position: absolute;
top: 31px;
transform: rotate(90deg);
z-index: 2;
}
.hovereffect:hover .overlay {
opacity: 1;
}
<div class="ala col-lg-3 col-md-3 col-sm-6 col-xs-12 col-md-25">
<span style="position: absolute;top: -25px;font-size:1rem;margin-left: -30px;color:#666;left: 50%;font-family:'Lato', sans-serif;display:block" class="rate"></span>
<div class="hovereffect clic">
<div class="clic" style="display:block"></div>
<div class="heart"></div>
<img class="img-responsive" src="image01.jpg" alt="namePhoto">
<div class="overlay">
<a class="info test-popup-link" href="image02.jpg"></a>
<br>
<br>
<br>
<br>
<br>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary check active">
<input class="ck" name="ck[]" checked="" value="1" id="ck_1" type="checkbox"> <span class="che">Desmarcar</span>
</label>
</div>
</div>
</div>
</div>
strong text
I have a tooltip to show my search when hovering over an icon. That works fine in itself.
My problem is, that this icon is inside an inline-block navigation and cause it acts as the parent of my tooltip it has to have the large width of it which messes up my layout.So if I don't extend the width of my parent with the Icon the Tooltip messes up due to the small width of ~30px of it's parent.
If I extend the width from my parent to 300px (The size of my tooltip), it messes up my layout.
I need a way of relieving the tooltip itself from the inside of the element with the Icon.
HTML Structure:
<div id="search">
<div class="wrapper">
<div class="popper inline">
<i class="fa fa-tags" />
<div class="tooltip">
<form>
<input placeholder="Search Tags" autocomplete="off" />
<button type="submit">
<a class="btn">
<i class="fa fa-search" />
</a>
</button>
</form>
</div>
<div class="inline">
<form>
<input placeholder="Search Tags" autocomplete="off" autofocus="true" />
<button type="submit">
<a class="btn">
<i class="fa fa-search" />
</a>
</button>
</form>
</div>
</div>
</div>
CSS (Scss):
#search {
background: $secondary;
padding: .25rem;
div.popper {
background: transparent;
border: none;
font-size: .8rem;
color: $highlight;
}
.inline form {
button, input, a {
background: transparent;
border: none;
font-size: .8rem;
color: $highlight;
}
input[type="Search"] {
width: 1368px;
outline: none;
font-style: italic;
font-size: .7rem;
padding: 1rem .5rem;
}
button {
margin-left: 1rem;
}
}
}
.popper {
position: relative;
width: 300px;
}
.popper .tooltip {
background: $secondary;
bottom: 100%;
color: $highlight;
display: block;
left: -25px;
margin-bottom: 20px;
opacity: 0;
padding: .8rem;
pointer-events: none;
position: absolute;
width: 300px;
max-width: 90%;
border-radius: 3px;
-webkit-transform: translateY(10px);
-moz-transform: translateY(10px);
-ms-transform: translateY(10px);
-o-transform: translateY(10px);
transform: translateY(10px);
-webkit-transition: all .25s ease-out;
-moz-transition: all .25s ease-out;
-ms-transition: all .25s ease-out;
-o-transition: all .25s ease-out;
transition: all .25s ease-out;
}
/* This bridges the gap so you can mouse into the tooltip without it disappearing */
.popper .tooltip:before {
bottom: -20px;
content: " ";
display: block;
height: 25px;
left: 0;
position: absolute;
width: 100%;
}
/* CSS Triangles - see Trevor's post */
.popper .tooltip:after {
border-left: solid transparent 7px;
border-right: solid transparent 7px;
border-top: solid $secondary 7px;
bottom: -7px;
content: " ";
height: 0;
left: 50%;
margin-left: -13px;
position: absolute;
width: 0;
}
.popper:hover .tooltip {
opacity: 1;
pointer-events: auto;
-webkit-transform: translateY(0px);
-moz-transform: translateY(0px);
-ms-transform: translateY(0px);
-o-transform: translateY(0px);
transform: translateY(0px);
}
I am grateful for all Your help! If you need further information, comment please.
For navigation, I opted to use CSS shapes rather than images with overlaid text. However, in every browser, the text appears misaligned towards the right.
Preview on jsFiddle
HTML code:
<nav id="globalNav">
<ul>
<li>
<div class="stars"></div>
<a id="navHome">home</a>
</li>
<li>
<div class="stars"></div>
<a id="navWork">work</a>
</li>
<li>
<div class="stars"></div>
<a id="navAbout">about</a>
</li>
</ul>
</nav>
CSS code:
#globalNav {
position: fixed;
z-index: 1;
width: 100%;
height: 100px;
top: 0;
left: 0;
overflow: hidden;
background-color: #1b2326;
color: #2A363B;
}
#globalNav ul {
margin: 1.25em auto;
padding: 0;
position: relative;
-webkit-padding-start: 0;
-moz-padding-start: 0;
text-align: center;
}
#globalNav li {
padding: 0 3.5em;
display: inline-block;
}
#globalNav a {
position: absolute;
top: 1.3em;
padding: 0 0.25em;
-moz-padding-start: 0;
font-size: 1em;
text-transform: uppercase;
color: #FECEA8;
}
#globalNav a:hover {
position: absolute;
top: 1.3em;
padding: 0 0.25em;
-moz-padding-start: 0;
font-size: 1em;
text-transform: uppercase;
color: #ED6161;
-webkit-transition: .3s ease-in;
-moz-transition: .3s ease-in;
-ms-transition: .3s ease-in;
-o-transition: .3s ease-in;
transition: .3s ease-in;
}
/* dodecagram stars */
.stars {
background: #2A363B;
width: 60px;
height: 60px;
position: relative;
}
.stars:before, .stars:after {
content: "";
position: absolute;
top: 0;
left: 0;
height: 60px;
width: 60px;
background: #2A363B;
}
.stars:before {
-webkit-transform: rotate(30deg);
-moz-transform: rotate(30deg);
-ms-transform: rotate(30deg);
-o-transform: rotate(30deg);
}
.stars:after {
-webkit-transform: rotate(60deg);
-moz-transform: rotate(60deg);
-ms-transform: rotate(60deg);
-o-transform: rotate(60deg);
}
I already searched the forum (i.e., Center text with background CSS “shape”), however the solution didn't work for me.
Add the following CSS to your <a> tags inside the shapes and they will align in the center of the shape :)
position: absolute;
top: 1.3em;
-moz-padding-start: 0;
font-size: 1em;
text-transform: uppercase; /* Also, note that I removed the padding */
color: #FECEA8;
display: block;
width: 60px;
word-wrap: break-word;
}
http://jsfiddle.net/TVkNK/7/
Adding text-align:center to the css did it for me. I also used padding-top to add appropriate padding for vertical centering.