I have two html elements. The second element is hidden. But when hovering on first element the second one will be visible. These are two separate elements not linked. I'm trying to do this using css variables. On hover it's not getting visible.
CSS
#copyright-ft
{
position: absolute;
overflow: visible;
font-family: roboto, cus-roboto, sans-serif;
font-size: 70px;
padding-left: 25px;
padding-right: 22px;
color: rgba(0,0,0,0.45);
border: 4px rgba(236,96,202,0.24) solid;
border-radius: 80px;
top: 14px;
left: 25px;
padding-top: 10px;
padding-bottom: 7px;
}
#copyright-ft-details
{
position: absolute;
overflow: visible;
font-family: roboto, cus-roboto, sans-serif;
font-size: 40px;
padding-left: 35px;
padding-right: 35px;
color: rgba(255,255,255,0.7);
border: 0px rgba(236,96,202,0.24) solid;
border-radius: 10px;
top: 325px;
left: 120px;
padding-top: 15px;
padding-bottom: 15px;
background: rgba(0,0,0,0.7);
visibility: var(--copy-vsb);
--copy-vsb: hidden;
}
#copyright-ft:hover
{
--copy-vsb: visible;
}
HTML
<span id="copyright-ft"> <p>©</p> </span>
<div id="copyright-ft-details">
<span> elomymelo.com </span>
</div>
Can I do this with css without javascript event?
This is similar to a tooltip. You don't need to use a CSS variable. Here's the code:
#copyright-ft {
position: absolute;
overflow: visible;
font-family: roboto, cus-roboto, sans-serif;
font-size: 70px;
padding-left: 25px;
padding-right: 22px;
color: rgba(0, 0, 0, 0.45);
border: 4px rgba(236, 96, 202, 0.24) solid;
border-radius: 80px;
top: 14px;
left: 25px;
padding-top: 10px;
padding-bottom: 7px;
}
#copyright-ft-details {
position: absolute;
overflow: visible;
font-family: roboto, cus-roboto, sans-serif;
font-size: 40px;
padding-left: 35px;
padding-right: 35px;
color: rgba(255, 255, 255, 0.7);
border: 0px rgba(236, 96, 202, 0.24) solid;
border-radius: 10px;
top: 325px;
left: 120px;
padding-top: 15px;
padding-bottom: 15px;
background: rgba(0, 0, 0, 0.7);
visibility: hidden;
}
#copyright-ft:hover ~ #copyright-ft-details {
visibility: visible;
}
<span id="copyright-ft">
<p>©</p>
</span>
<div id="copyright-ft-details">
<span> elomymelo.com </span>
</div>
From MDN:
Custom properties are scoped to the element(s) they are declared on,
and participate in the cascade: the value of such a custom property
is that from the declaration decided by the cascading algorithm.
So I guess you can't alter the "global" variable even if you declare it on :root or body first; #copyright-ft:hover{--copy-vsb} may just make a local variable with the same name (notice the example in the MDN document).
CSS selectors mostly works only in descendant direction: from parent to child and from first child to last child. So if your #copyright-ft-details is ALWAYS a late sibling and/or child of #copyright-ft, you can try something like this:
#copyright-ft
{
position: absolute;
overflow: visible;
font-family: roboto, cus-roboto, sans-serif;
font-size: 70px;
padding-left: 25px;
padding-right: 22px;
color: rgba(0,0,0,0.45);
border: 4px rgba(236,96,202,0.24) solid;
border-radius: 80px;
top: 14px;
left: 25px;
padding-top: 10px;
padding-bottom: 7px;
}
#copyright-ft-details
{
position: absolute;
overflow: visible;
font-family: roboto, cus-roboto, sans-serif;
font-size: 40px;
padding-left: 35px;
padding-right: 35px;
color: rgba(255,255,255,0.7);
border: 0px rgba(236,96,202,0.24) solid;
border-radius: 10px;
top: 325px;
left: 120px;
padding-top: 15px;
padding-bottom: 15px;
background: rgba(0,0,0,0.7);
visibility: hidden;
}
#copyright-ft:hover ~ #copyright-ft-details,/* late sibling */
#copyright-ft:hover #copyright-ft-details,/* child */
#copyright-ft:hover ~ * #copyright-ft-details/* late sibling and child */
{
visibility: visible;
}
<span id="copyright-ft"> <p>©</p> </span>
<div id="copyright-ft-details">
<span> elomymelo.com </span>
</div>
You can use the General Sibling Combinator ~ to target the id you want to display on hovering your other ID.
#copyright-ft {
position: absolute;
overflow: visible;
font-family: roboto, cus-roboto, sans-serif;
font-size: 70px;
padding-left: 25px;
padding-right: 22px;
color: rgba(0, 0, 0, 0.45);
border: 4px rgba(236, 96, 202, 0.24) solid;
border-radius: 80px;
top: 14px;
left: 25px;
padding-top: 10px;
padding-bottom: 7px;
cursor: pointer;
}
#copyright-ft-details {
position: absolute;
overflow: visible;
font-family: roboto, cus-roboto, sans-serif;
font-size: 40px;
padding-left: 35px;
padding-right: 35px;
color: rgba(255, 255, 255, 0.7);
border: 0px rgba(236, 96, 202, 0.24) solid;
border-radius: 10px;
top: 325px;
left: 120px;
padding-top: 15px;
padding-bottom: 15px;
background: rgba(0, 0, 0, 0.7);
visibility: hidden;
}
#copyright-ft:hover~#copyright-ft-details {
visibility: visible;
}
<span id="copyright-ft">
<p>©</p>
</span>
<div id="copyright-ft-details">
<span> elomymelo.com </span>
</div>
Related
I've got the button to float down the page as the user scroll's down the page, but is there a way to make it that after scrolling all the way to the bottom that it stays above the footer at all times.
I've tried to z-index, but all the solution I've found use javascript/jquery, I need it to be pure html and css
edited: the footer code is located under the button code in the html, also how do you make sure that regardless of the size of the page, the footer stays stays stuck to the bottom.
.footer {
text-align: center;
padding-top: 20px;
padding-bottom: 20px;
background-color: #1B1B1B;
color: #FFFFFF;
text-transform: uppercase;
font-weight: lighter;
letter-spacing: 2px;
border-top-width: 2px;
padding: 2px;
color: #ffffff;
width: 100%;
position: static;
font-weight: 200;
bottom: 10px;
}
/*Floating Back-To-Top Button*/
#myBtn {
position: fixed;
bottom: 10px;
float: right;
right: 18.5%;
left: 77.25%;
max-width: 50px;
width: 100%;
font-size: 12px;
border-color: rgba(85, 85, 85, 0.2);
background-color: rgb(100, 100, 100);
padding: .5px;
border-radius: 4px;
z-index: 1000;
}
/*On Hover Color Change*/
#myBtn:hover {
background-color: #7dbbf1;
}
<button id="myBtn">Top</button>
<div class="footer">
<p><span>Aditya's Website | Websystems Assignment | Copyright © 2019</span></p>
Home | Past | Future | Comments
</div>
button is coming on top of footer. please check the code.. Or add the footer HTML and CSS in the Question
.footer {
text-align: center;
padding-top: 20px;
padding-bottom: 20px;
background-color: red;
color: #FFFFFF;
text-transform: uppercase;
font-weight: lighter;
letter-spacing: 2px;
border-top-width: 2px;
padding: 2px;
width: 100%;
font-weight: 200;
bottom: 10px;
height: 30px;
position: absolute;
bottom: 0;
}
/*Floating Back-To-Top Button*/
#myBtn {
position: fixed;
bottom: 10px;
float: right;
right: 18.5%;
left: 77.25%;
max-width: 50px;
width: 100%;
font-size: 12px;
border-color: rgba(85, 85, 85, 0.2);
background-color: rgb(100, 100, 100);
padding: .5px;
border-radius: 4px;
z-index: 1000;
}
/*On Hover Color Change*/
#myBtn:hover {
background-color: #7dbbf1;
}
<button id="myBtn">Top</button>
<footer class="footer">
</footer>
I have a requirement of displaying the image/icon on top of the modal box in a semicircle. Though I have achieved it with the help of below code, but the only issue is whenever my form in the modal box goes for a validation check, displaying any error, my semicircle doesn't get adjusted accordingly, rather it stays at its position. Here, I have attached the screen shot of what exactly I am looking for and HTML/css code I have used to display the semicircle with image/icon at the top.
.modal {
font-family: Avenir-Medium;
font-size: 16px;
font-weight: 900;
font-style: normal;
font-stretch: normal;
display: block;
/*Hidden by default */
position: fixed;
/* Stay in place */
z-index: 1;
/* Sit on top */
left: 0;
top: 0;
width: 100%;
/* Full width */
height: 100%;
/* Full height */
overflow: auto;
/* Enable scroll if needed */
background-color: rgb(0, 0, 0);
/* Fallback color */
background-color: rgba(0, 0, 0, 0.3);
/* Black w/ opacity */
-webkit-animation-name: slideIn;
/* Fade in the background */
-webkit-animation-duration: 2.0s;
/* Fade in the background */
;
}
/* Modal Content */
.modal-content {
position: fixed;
bottom: 0;
background-color: #fefefe;
width: 92%;
left: 14px;
-webkit-animation-name: fadeIn;
-webkit-animation-duration: 0.5s;
border-radius: 16px 16px 0px 0px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
border: none;
top: auto;
}
.modal-wrapper {
line-height: 45px;
border: 1px solid #e7e9ea;
border-radius: 6px 6px 0px 0px;
background-color: white;
margin: auto;
}
.modal-wrapper::after {
background: url("../../../../images/mobile/img-payment_38.png") no-repeat 22px 10px;
background-size: 50%;
background-color: #fff;
content: '';
width: 78px;
height: 45px;
position: absolute;
left: 0;
right: 0;
margin: auto;
border-radius: 78px 78px 0 0;
border-left: 1px solid #e7e9ea;
border-top: 1px solid #e7e9ea;
border-right: 1px solid #e7e9ea;
border-bottom: 3px solid white;
bottom: 300px;
}
.close-btn {
position: absolute;
vertical-align: top;
top: 4px;
left: 320px;
width: 18px;
height: 18px;
}
.container-div-creditCard {
margin: 12px 20px 0px 20px;
}
.container-div-creditCard>img {
position: absolute;
bottom: 154px;
right: 30px;
}
.credit-card-modal-label {
font-family: AvenirHeavy;
font-size: 13px;
color: #1d3444;
text-align: center;
font-weight: 200;
height: 24px;
margin-left: 31px;
}
.input-modal {
width: 100%;
height: 44px;
}
.input-spacing {
margin-top: 15px;
}
.credit-input-modal {
border: solid 1px #e7e9ea;
border-radius: 5px;
font-family: Avenir-Book;
font-size: 14px;
font-weight: normal;
color: #8589a1;
line-height: initial;
padding: 13px 42px 12px 15px;
}
.credit-expiry-input-modal {
padding: 13px 27px 12px 10px;
border: solid 1px #e7e9ea;
border-radius: 5px;
font-family: Avenir-Book;
font-size: 14px;
font-weight: normal;
color: #8589a1;
display: inline-block;
line-height: initial;
width: 65%;
height: 44px;
}
.credit-cvc-input-modal {
width: 30%;
padding: 17px 5px 12px 10px;
border: solid 1px #e7e9ea;
border-radius: 5px;
font-family: Avenir-Book;
font-size: 14px;
font-weight: normal;
color: #8589a1;
line-height: initial;
height: 44px;
}
.cvvDisc {
-webkit-text-security: disc;
}
.credit-submit-button {
width: 100%;
padding: 13px;
margin-top: 15px;
border: solid 1px #e7e9ea;
border-radius: 5px 5px 5px 5px;
background: linear-gradient(to right, #e32490, #ed1a3d);
color: white;
margin-bottom: 20px;
font-family: Avenir-Book;
font-weight: normal;
font-size: 14px;
line-height: initial;
}
.errorMsg {
font-family: Avenir-Book;
font-weight: normal;
color: #ED1A3D;
font-size: 12px;
}
<div id="modalCCDetails" class="modal">
<div class="modal-content modal-wrapper">
<div class="container-div-creditCard">
<label class="credit-card-modal-label">ENTER YOUR CREDIT CARD DETAILS</label>
<input name="cc_name" class="input-modal credit-input-modal" type="text" placeholder="Name printed on Credit Card" onChange={this.handleUserInput} />
<span class="errorMsg"></span>
<input name="cc_number" class="input-modal credit-input-modal input-spacing" type="tel" maxLength="16" onKeyPress={(e)=> this.handleCCOnKeyPress(e)} placeholder="16 digit credit card number" />
<span class="errorMsg"></span>
<input name="cc_expDate" class="credit-expiry-input-modal" type="text" placeholder="Expiry MM-YYYY" />
<div class="device-divider" />
<input name="cc_cvc" class="credit-cvc-input-modal cvvDisc" type="tel" placeholder="CVC" maxLength="3" />
<span class="errorMsg"></span>
</div>
<button class="credit-submit-button">Submit Payment</button>
</div>
</div>
</div>
NOTE: This is a mobile view screenshot
Just adjust your css code into something like this:
.modal-wrapper::after {
background: url("../../../../images/mobile/img-payment_38.png") no-repeat 22px 10px;
background-size: 50%;
background-color: #fff;
content: '';
width: 78px;
height: 45px;
position: absolute;
left: 0;
right: 0;
margin: auto;
border-radius: 78px 78px 0 0;
border: 1px solid #e7e9ea;
border-bottom: 3px`enter code here` solid white;
top: -48px;
}
Just remove the bottom: 300px; and replace with top: -48px; or any value that you want.
please add top:-15px; and removed bottom:300px; in class .modal-wrapper::after { top: -15px; }, u will see the image move up
I am new to CSS and I have created a website but after whole work is done my all css elements are getting disordered on screen while minimizing the browser window..how to solve this?
I thought I should have provided the % value instead of pixels value...bt its also not working...
Please Help!
One of the stylesheet having this problem is...
.card-panel{
transition: box-shadow .25s;
padding: 20px;
padding-left: 150px;
margin: 0.5rem 0 1rem 0;
border-radius: 2px;
background-color: #f0f8ff ;
box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
position:absolute;
top: 100px;
left: 300px;
bottom:300px;
right: 300px;
font-family: calibri;
font-size: 18px;
color: #708090;
z-index: 2;
}
body{
background: #dcdcdc;
}
.profile{
float: right;
position: absolute;
left: 50px;
top: 33px;
bottom:40px;
padding-top: 0px;
padding-left: 0px;
border: 5px solid #708090;
}
.name{
color: #3299cc;
font-weight: bold;
font-size: 30px;
position: relative;
top: 10px;
left: 60px;
font-family: cambria;
}
.profession{
color: #3299cc;
font-size: 15px;
position: relative;
top: 16px;
left: 60px;
font-family: cambria;
}
span{
color: #708090;
}
You should try to use any Front-end frameworks like bootstrap, foundation, skeleton, frame etc. This will solve your problem.
As you've mentioned you're new to css, I strongly recommend you to use skeleton or frame
How to apply this css for move element text "DOG DOG DOG" to top over cat image ?
i test in chrome it's ok
http://image.ohozaa.com/i/g53/BwHNe9.png
but in ie7 element text DOG DOG DOG not move to top cat image
http://image.ohozaa.com/i/53f/8OqTpZ.png
how to apply css ?
<div style=" display: block;
opacity: 1;
color: rgb(255, 255, 255);
width: 80px;
height: 80px;
position: relative;
float: left;
background: #fff;
margin: 7px;">
<div style="
left: 25px; top: 13px; z-index: 999; opacity: 1; -webkit-backface-visibility: hidden; color: #fff; font-weight: bold; width: 117px; text-align: center; font-size: 12px; font-family: lato; padding: 10px 0px; position: absolute; margin: 0px; background-color: rgb(0, 178, 45); -moz-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px ;
">
DOG DOG DOG
</div>
<img src="http://green.uwex.edu/files/2010/06/4-H-Dog.png" width="80" height="80" style=" border: 1px solid rgb(203, 203, 203); ">
</div>
<div style=" display: block;
opacity: 1;
color: rgb(255, 255, 255);
width: 80px;
height: 80px;
position: relative;
float: left;
background: #fff;
margin: 7px;">
<div style="
left: 25px; top: 13px; z-index: 999; opacity: 1; -webkit-backface-visibility: hidden; color: #fff; font-weight: bold; width: 117px; text-align: center; font-size: 12px; font-family: lato; padding: 10px 0px; position: absolute; margin: 0px; background-color: rgb(0, 178, 45); -moz-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px;
">
CAT CAT CAT
</div>
<img src="http://img1.wikia.nocookie.net/__cb20120908225005/disney/images/thumb/b/b6/Cheshirecatdisney.png/256px-Cheshirecatdisney.png" width="80" height="80" style=" border: 1px solid rgb(203, 203, 203); ">
</div>
now check work fine in ie 7... in body tag first div you change the css
<div style=" display: block;
opacity: 1;
color: rgb(255, 255, 255);
width: 80px;
height: 80px;
position: relative;
*position: absolute; /* for ie 7 only */
float: left;
background: #fff;
margin: 7px;">
I would like to move the circle down by 15px with CSS as an image below. I've attempted with padding-bottom or margin-bottom in the .circle class, yet it did work in another way as making the circle longer than itself.
HTML:
<table id="showRoom">
<tr class="box_shadow">
<td>
<div class="news_column1">
<a target="_blank" href="http://google.com">
<span class="circle">P1</span>
<span class="imgswap">Showroom 1</span>
<div class="news_img">
<div>
<p>Book Now!</p>
</div>
</div>
</a>
</div>
</td>
</tr>
</table>
CSS:
body {
background-color: #F6F6F6;
}
#showRoom {
margin-left: 10px;
margin-top: 20px;
width: auto;
border-collapse: collapse;
}
table td {
padding: 0;
}
table .box_shadow {
background-color: #FFF;
font-size: 18px;
line-height: 20px;
text-align: center;
font-weight: normal;
font-family: 'Scada', sans-serif;
display: block;
-webkit-box-shadow: -4px 4px 5px 0px rgba(50, 50, 50, 0.3);
-moz-box-shadow: -4px 4px 5px 0px rgba(50, 50, 50, 0.3);
box-shadow: -4px 4px 5px 0px rgba(50, 50, 50, 0.3);
}
table tr .text_plant_address {
background-color: #FFF;
width: 200px;
height: 200px;
line-height: 20px;
text-align: center;
font-weight: normal;
font-family: 'Scada', sans-serif;
margin: 0;
padding: 0;
}
table tr td span {
height: 195px;
width: auto;
}
table tr td div {
width: 200px;
height: 200px;
position: relative;
}
table tr td a {
text-decoration: none;
}
table tr td .text_plant {
border-bottom: 1px solid #D0D0D0;
font-family: ballpark_weiner, Arial;
font-size: 26px;
letter-spacing: 1px;
padding: 0 15px;
}
table tr td .text_address {
font-size: 10px;
font-family: Arial;
display: block;
position: relative;
height: auto;
margin-top: 5px;
}
.news_column1 {
background-color: #FF7F7F;
/*background-color: #FFF;*/
/*border-radius: 15px;*/
}
table tr td div:hover {
cursor: pointer;
}
.news_img {
width: 200px;
height: 70px;
text-align: center;
background-color: rgba(0, 0, 0, 0.4);
font-family: 'Times New Roman';
font-weight: bold;
letter-spacing: 0.5px;
display: none;
position: absolute;
bottom: 0;
left: 0;
opacity: 0.95;
/*border-radius: 0 0 15px 15px;*/
}
.news_img div {
width: 200px;
height: 10px;
margin: 0;
padding: 0;
display: table-cell;
vertical-align: middle;
}
.news_img div p {
display: block;
margin-top: 25px;
font-size: 17px;
color: #FFF;
transform: rotate(-10deg);
-ms-transform: rotate(-10deg);
/* IE 9 */
-webkit-transform: rotate(-10deg);
/* Opera, Chrome, and Safari */
}
span.circle {
width: 100px;
height: 100px;
font-size: 30px;
color: #fff;
line-height: 100px;
text-align: center;
background-color: #111111;
opacity: 0.3;
display: block;
margin: 0 50px 0 50px;
-webkit-border-radius: 50px;
-moz-border-radius: 50px;
border-radius: 50px;
}
span.imgswap {
display: block;
opacity: 0.5;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
font-family: sans-serif;
font-size: 20px;
padding-top: 10px;
font-family: Stark;
letter-spacing: 0.5px;
}
JSFIDDLE: http://jsfiddle.net/huydq91/rB5hX/7/
Just need to add padding to;
table tr td div {
width: 200px;
height: 200px;
position: relative;
padding-top:15px;
}
UPDATED JS FIDDLE
One solution is to add a padding-top:15px; to div.news_column1 as in this JFiddle snippet.
A question: are you stuck with the markup or do you have freedom to change it?
Make Changes in following class. It will come circle below
table tr td a {
text-decoration: none;
display: block;
padding: 40px 0 0 0;
}
and Reduce the height in following class
table tr td span
{
//height:''
}