when the screen gets smaller on my website, the elements go to irrelevant places. I did some research and thought I could remove it using '%' but it didn't work.
This is 1 scale:
This is 0.25 scale
/*my container*/
.container-home{
width: 100%;
height: 60rem;
display: flex;
align-items: center;
}
/*
the articles are here*/
.words {
display: flex;
flex-direction: column;
justify-content: center;
width: 60%;
height: 100vh;
margin-left: 25vh;
transition: 1.5s;
}
.header{
font-size: 5rem;
font-weight: 500;
}
.description {
display: block;
margin-top: 3rem;
font-size: 2rem;
}
/*explore text span*/
.explore{
margin-top: 2.5rem;
width: 15rem;
height: 4rem;
text-align: center;
display: block;
font-size: 2rem;
border: 0.1rem solid #000;
border-radius: 2.5rem;
margin-left: 1.5rem;
position: relative;
z-index: 1;
}
/*explore text a*/
.explore a{
display: block;
text-decoration: none;
font-size: 2rem;
color: #000;
text-align: center;
margin-top: 0.7rem;
}
.explore:hover {
border-color: transparent;
text-align: center;
transition: 1s;
transform: translateY(0.6rem) translateX(-1rem);
}
/*colored rectangle under text explore*/
.explore-hover{
display: inline;
position: absolute;
width: 15rem;
height: 4rem;
border-radius: 2.5rem;
background-color: #f1e0d4;
top: 42rem;
}
/*circle , solid circle and image in this*/
.image-design{
width: 100%;
height:100vh;
}
.circle{
position: relative;
width: 100%;
height: 100%;
clip-path: circle(300px at center);
background-color: #d7e7f1;
margin-top:8rem;
}
.solid-circle{
position: absolute;
width: 60rem;
height: 60rem;
border-radius: 50%;
background-color: transparent;
top: 30%;
left: 28%;
border: 1px solid #3398d7;
}
/*I created it to put an image on top of the circles*/
.conainer-image-design{
position: absolute;
width: 100%;
left: 25rem;
height:100vh;
}
.image{
position: relative;
top: 25%;
left: 12%;
}
<div class="container-home">
<div class="words">
<span class="header">
Handcrafted<br>
& ethically sourced
</span>
<span class="description">A collection inspired by old-world charm, crafted
<br>with moisannites and diamonds.
</span>
<span class="explore">Explore→</span>
<div class="explore-hover"></div>
</div>
<div class="image-design">
<div class="conainer-image-design">
<div class="circle"></div>
<div class="solid-circle"></div>
</div>
<span class="image"><img src="./ring.png"></span>
</div>
</div>
what do you recommend to give the measurements, I mainly use rem or % .which is better to keep the image intact?
Related
body {
margin: 0px;
}
.items_container {
display: flex;
align-items: center;
width: 100%;
height: 50px;
background-color: rgb(200,200,200);
}
.circle_container {
display: flex;
align-items: center;
position: relative;
z-index: 100;
}
.circle {
position: absolute;
margin: 0px 10px;
border: 0.5px solid black;
width: 50px;
height: 50px;
border-radius: 50%;
background-color: black;
}
.btext {
padding: 0px;
margin: 0px;
color: white;
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
hr {
position: absolute;
width: 100%;
z-index: 90;
}
.finish_container {
display: flex;
justify-content: flex-end;
align-items: center;
position: relative;
width: 100%;
z-index: 95;
}
.finish {
position: absolute;
margin: 0px 10px;
border: 0.5px solid black;
width: 50px;
height: 50px;
border-radius: 50%;
background-color: white;
}
.wtext {
padding: 0px;
margin: 0px;
color: black;
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
}
<div class="items_container">
<div class="circle_container">
<div class="circle">
<p class="btext">
Start
</p>
</div>
</div>
<hr>
<div class="finish_container">
<div class="finish">
<p class="wtext">
Finish
</p>
</div>
</div>
</div>
I want to roll black (start) circle to the white (finish) circle with smooth animation. Is it possible to make this? If it is, how can i do that?
![Do not mind this sentence. System gives an error that says 'It looks like your post is mostly code; please add some more details.' For posting my question I am adding this, sorry.]!
<div classname="rotate"></div>
#keyframes anirotate {
0% {
transform: translateX(0) rotate(0);
}
100%{
transform: translateX(100px) rotate(360deg);
}
}
.rotate::after{
content: 'Start'
}
.rotate{
width : 200px;
height: 200px;
border-radius: 50%;
background-color: lightblue;
animation : anirotate 2s 0s 1 forwards;
}
This question already has answers here:
How to affect other elements when one element is hovered
(9 answers)
Closed 8 months ago.
I need to make when hovering over a div with an image, there is black background with opacity and when hovering over the button, it changes its values. I got the following:
.promo__girl {
background-repeat: no-repeat;
background-image: url('https://i.ibb.co/r0rnSP0/1.png');
position: absolute;
width: 300px;
height: 300px;
margin-top: 136px;
right: 7.469rem;
border-radius: 10px;
display: flex;
justify-content: center;
align-items: center;
}
.promo__girl-image {
width: 100%;
}
.promo__girl-hover {
width: 300px;
height: 300px;
border-radius: 10px;
position: absolute;
display: flex;
justify-content: center;
align-items: center;
}
.promo__girl .button_yellow {
font-size: 16px;
color: #162E3C;
background-color: #DDF0A7;
border: 2px solid #DDF0A7;
text-align: center;
margin-top: 10px;
border-radius: 64px;
margin-right: 4px;
height: 52px;
width: 233px;
z-index: 1;
}
.promo__girl .button_yellow:hover {
width: 233px;
background-color: inherit;
color: white;
border-color: white;
opacity: 1;
}
.promo__girl-hover:hover {
background-color: black;
opacity: 0.7;
transition: 0.5s;
}
<div class="promo__girl">
<div class="promo__girl-hover"><button class="button_yellow">Watch Introduction</button></div>
</div>
So now when i hovering image, opacity applies to button to, but i donr need it. Maybe someone will help me? Maybe you can do this with display:none or visibility: hidden/visible? I tried it but there is 0 result.
You can't override parent opacity in a child. But you can use "another" element to be darker... the :after pseudo element. It works.
.promo__girl {
background-repeat: no-repeat;
background-image: url('https://i.ibb.co/r0rnSP0/1.png');
position: absolute;
width: 300px;
height: 300px;
margin-top: 136px;
right: 7.469rem;
border-radius: 10px;
display: flex;
justify-content: center;
align-items: center;
}
.promo__girl-image {
width: 100%;
}
.promo__girl-hover {
width: 300px;
height: 300px;
border-radius: 10px;
position: absolute;
display: flex;
justify-content: center;
align-items: center;
}
.promo__girl .button_yellow {
font-size: 16px;
color: #162E3C;
background-color: #DDF0A7;
border: 2px solid #DDF0A7;
text-align: center;
margin-top: 10px;
border-radius: 64px;
margin-right: 4px;
height: 52px;
width: 233px;
z-index: 1;
}
.promo__girl .button_yellow:hover {
width: 233px;
background-color: inherit;
color: white;
border-color: white;
opacity: 1;
}
.promo__girl-hover:after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: black;
opacity: 0;
transition: 0.5s;
pointer-events: none;
}
.promo__girl-hover:hover:after {
opacity: 0.7;
transition: 0.5s;
}
<div class="promo__girl">
<div class="promo__girl-hover">
<button class="button_yellow">Watch Introduction</button>
</div>
</div>
I have searched all over stack overflow but I am unable to find any clue and I am struck here. I used flex container and child items in my code to some extent but I couldn't move beyond that. Thing is when we hover a child item, a new child item need to be created as shown in the expected result. Should we need to use pseudo element or any other flex properties to achieve this. Thanks much in advance.
My code:
https://jsfiddle.net/k2qr398u/1/
My result
https://imgur.com/kRHNHuu
Expected result:
https://imgur.com/2B6CkYF
/**CSS**/
body {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: sans-serif;
background-color: #400017;
}
.img-css {
width: 50px;
height: 50px;
}
.main-heading {
display: block;
text-align: center;
color: #fc065d;
margin-bottom: 70px;
}
.img-js {
width: 50px;
height: 50px;
}
.container {
display: flex;
justify-content: space-around;
align-items: center;
flex-wrap: wrap;
border: 3px solid #360310;
max-width: 610px;
height: 310px;
text-align: center;
margin: 0 auto;
flex-direction: row;
/* transform: translate(-50%,-50%); */
}
.col {
width: 130px;
height: 100px;
margin: 0 auto;
border: 3px solid #5e0a1f;
padding-top: 44px;
padding-left: 26px;
padding-right: 26px;
color: #fff;
background-color: #010001;
border-radius: 30px;
z-index: 20;
/* position: relative; */
}
.col p {
font-size: 16px;
font-weight: bold;
}
.col-2 p {
position: relative;
top: 55px;
text-align: center;
font-weight: bold;
}
<!--**HTML**-->
<body>
<div class="container">
<div class="col col-1">
<img src="images/css.svg" alt="CSS logo" class="img-css">
<br>
<p>I am</p>
</div>
<div class="col col-2">
<p class="my-name">Sri</p>
</div>
<div class="col col-3">
<img src="images/javascript.svg" alt="JS logo" class="img-js">
<p>Developer
</p>
</div>
</div>
</body>
P.S: Sorry if this question sounds very silly or dumb, I am a beginner trying to learn web dev skillsets.
I have created something similar to your expected result. Please run the code snippet for the result.
UPDATE: To include the hover off transition.
/**CSS**/
body {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: sans-serif;
background-color: #400017;
}
.img-css {
width: 50px;
height: 50px;
}
.main-heading {
display: block;
text-align: center;
color: #fc065d;
margin-bottom: 70px;
}
.img-js {
width: 50px;
height: 50px;
}
.container {
display: flex;
justify-content: space-around;
align-items: center;
flex-wrap: wrap;
border: 3px solid #360310;
max-width: 610px;
height: 310px;
text-align: center;
margin: 0 auto;
flex-direction: row;
/* transform: translate(-50%,-50%); */
}
.col {
width: 130px;
height: 100px;
margin: 0 auto;
border: 3px solid #5e0a1f;
padding-top: 44px;
padding-left: 26px;
padding-right: 26px;
color: #fff;
background-color: #010001;
border-radius: 30px;
z-index: 20;
position: relative;
}
.col p {
font-size: 16px;
font-weight: bold;
}
/*
.col-2 p {
position: relative;
top: 55px;
text-align: center;
font-weight: bold;
}
*/
.col-1,
.col-2-1,
.col-2-2,
.col-3 {
position: absolute;
left: 0;
top: 0;
transition: 1s;
}
.wrapper {
position: relative;
}
.wrapper:hover .col-1 {
transition: 1s;
left: -200px;
}
.wrapper:hover .col-2-1 {
transition: 1s;
top: -170px;
}
.wrapper:hover .col-2-2 {
transition: 1s;
top: 170px;
}
.wrapper:hover .col-3 {
transition: 1s;
left: 200px;
}
<!--**HTML**-->
<body>
<div class="container">
<div class="wrapper">
<div class="col"> Underneath</div>
<div class="col col-1">
<img src="images/css.svg" alt="CSS logo" class="img-css">
<br>
<p>I am</p>
</div>
</div>
<div class="wrapper">
<div class="col"> Underneath</div>
<div class="col col-2-1">
<p class="my-name">Sri</p>
</div>
<div class="col col-2-2">
<p class="my-name">Pratham</p>
</div>
</div>
<div class="wrapper">
<div class="col"> Underneath</div>
<div class="col col-3">
<img src="images/javascript.svg" alt="JS logo" class="img-js">
<p>Developer
</p>
</div>
</div>
</div>
</body>
The idea is:
Overlay some content over main content.
On hover reveal it :)
.card {
width: 150px;
height: 80px;
border: 1px solid #999;
background: #ccc;
border-radius: 8px;
position: relative;
margin: 20% auto;
}
.card:hover > .o-top {
top: -80px;
background: #f00;
}
.card:hover > .o-bottom {
bottom: -80px;
}
.o-top {
top: 0;
transition: top 1.5s, background 2s;
}
.o-bottom {
bottom: 0;
transition: bottom 1.5s, background 2s;
}
.card-overlay {
position: absolute;
height: 100%;
width: 100%;
background: #333;
pointer-events: none;
color: #fff;
}
<div class="card">
<div class="card-overlay o-top">TOP OVERLAY</div>
<div class="card-overlay o-bottom">BOTTOM OVERLAY</div>
<H3>INTERNAL CONTENT</H3>
</div>
The interview-box-container is where it should be when using flexbox, but I can't align any of the internal elements of the div.
Text-align doesn't influence the text b/c of flexbox; tried to do w/o flexbox and used vertical-align: center w/o luck.
Hoping to find a solution where I can use flexbox and be able to align internal content/elements inside the box.
body {
height: 100%;
width: 100%;
}
.interview-banner {
width: 100%;
height: 95px;
background-color: #19283B;
position: fixed;
z-index: 1;
}
.interview-background {
background-color: #F4F8FB;
min-height: 100vh;
height: 100%;
}
.interview-box-container {
/*align-items: center;
justify-content: center;
display: flex;
flex-direction: row;*/
vertically-align: center;
}
.interview-box {
position: relative;
border: 2px solid black;
max-width: 625px;
width: 100%;
min-height: 446px;
/*display: flex;
flex-direction: column;
align-items: center; */
padding: 35px;
background: white;
margin-top: 100px;
margin-bottom: 80px;
}
/*should be sitting on the right*/
.interview-box>button {
position: absolute;
bottom: 35px;
width: 108px;
height: 41px;
font-family: OpenSans-Light;
font-size: 15px;
text-align: center;
color: #FFFFFF;
background-color: #19283B;
border: 1px solid #19283B;
border-radius: 4px;
}
/*should be on the left*/
.interview-box > p {
text-align: right;
color: red;
}
<div class="interview-banner"></div>
<section class="interview-background">
<h2 class="interview-header">Header Text</h2>
<div class="interview-box-container">
<div class="interview-box">
<p>Explanation text</p>
<button>Button Text</button>
</div>
</div>
</section>
You can set justify-content: center; in .interview-box-container and few other tweaks such as removing position:absolute from button (see comments in snippet)
Note: there isn't value center for property vertical-align, the closest you find is the middle value
body {
height: 100%;
width: 100%;
margin: 0
}
.interview-banner {
width: 100%;
height: 95px;
background-color: #19283B;
position: fixed;
z-index: 1;
}
.interview-background {
background-color: #F4F8FB;
min-height: 100vh;
height: 100%;
}
.interview-box-container {
display: flex;
justify-content: center; /*align box in center */
}
.interview-box {
/*position: relative; */
border: 2px solid black;
max-width: 625px;
min-height: 446px;
display: flex;
flex-direction: row-reverse; /* to make button on left and text on right*/
align-items: center; /* align the text and button vertically*/
justify-content: space-between; /* items are evenly distributed in the line; first item is on the start line, last item on the end line*/
padding: 35px;
background: white;
margin: 100px 0 80px
}
.interview-box>button {
/* position: absolute;
bottom: 35px;*/
width: 108px;
height: 41px;
font-family: OpenSans-Light;
font-size: 15px;
text-align: center;
color: #FFFFFF;
background-color: #19283B;
border: 1px solid #19283B;
border-radius: 4px;
}
.interview-box>p {
color: red;
}
<div class="interview-banner"></div>
<section class="interview-background">
<h2 class="interview-header">Header Text</h2>
<div class="interview-box-container">
<div class="interview-box">
<p>Explanation text</p>
<button>Button Text</button>
</div>
</div>
</section>
Although I don't know what is your point with this markup, it can be simplified like this:
body {
height: 100%;
width: 100%;
margin: 0
}
.interview-banner {
width: 100%;
height: 95px;
background-color: #19283B;
position: fixed;
z-index: 1;
}
.interview-background {
background-color: #F4F8FB;
min-height: 100vh;
height: 100%;
}
.interview-box-container {
border: 2px solid black;
max-width: 625px;
min-height: 446px;
display: flex;
flex-direction: row-reverse; /* to make button on left and text on right*/
align-items: center; /* align the text and button vertically*/
justify-content: space-between; /* items are evenly distributed in the line; first item is on the start line, last item on the end line*/
padding: 35px;
background: white;
margin: 100px auto 80px
}
.interview-box-container>button {
/* position: absolute;
bottom: 35px;*/
width: 108px;
height: 41px;
font-family: OpenSans-Light;
font-size: 15px;
text-align: center;
color: #FFFFFF;
background-color: #19283B;
border: 1px solid #19283B;
border-radius: 4px;
}
.interview-box-container>p {
color: red;
}
<div class="interview-banner"></div>
<section class="interview-background">
<h2 class="interview-header">Header Text</h2>
<div class="interview-box-container">
<p>Explanation text</p>
<button>Button Text</button>
</div>
</section>
You can try margin to align the box and flex inside it by using space-between :
body {
height: 100%;
width: 100%;
}
.interview-banner {
width: 100%;
height: 95px;
background-color: #19283B;
position: fixed;
z-index: 1;
}
.interview-background {
background-color: #F4F8FB;
min-height: 100vh;
height: 100%;
}
.interview-box {
position: relative;
border: 2px solid black;
max-width: 625px;
width: 100%;
min-height: 446px;
margin:100px auto 80px;
display: flex;
align-items: center;
padding: 35px;
background: white;
margin-top: 100px;
margin-bottom: 80px;
justify-content:space-between;
}
.interview-box>button {
width: 108px;
font-family: OpenSans-Light;
font-size: 15px;
text-align: center;
color: #FFFFFF;
background-color: #19283B;
border: 1px solid #19283B;
border-radius: 4px;
}
.interview-box>p {
text-align: right;
color: red;
}
<div class="interview-banner"></div>
<section class="interview-background">
<h2 class="interview-header">Header Text</h2>
<div class="interview-box-container">
<div class="interview-box">
<p>Explanation text</p>
<button>Button Text</button>
</div>
</div>
</section>
I have a block with several items. When I click on the menu item it is highlighting and extending to the left border of the window.
I did this with the help of an absolutely positioned element, and set the width to 1000px, but this option does not work. This red bar should rest against the edge of the window at any resolution.
html
<div class="flex-menu-area">
<div class="container">
<div class="flex-menu">
<div class="left-flex-column">
<div class="flex-menu-select"><span>item 1</span></div>
<div class="flex-menu-select"><span>item 2</span></div>
<div class="flex-menu-select"><span>item 3</span></div>
</div>
<div class="right-left-column">
<div class="object"><span>item1content</span></div>
<div class="object"><span>item1content</span></div>
<div class="object"><span>item1content</span></div>
<div class="object"><span>item1content</span></div>
<div class="object"><span>item1content</span></div>
</div>
</div>
</div>
</div>
css
.flex-menu-area {
background: #fff;
width: 100%;
height: 512px;
.flex-menu {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
height: 100%;
.left-flex-column {
max-width: 256px;
width: 100%;
outline: 1px solid gray;
height: 512px;
.flex-menu-select {
font-size: 20px;
line-height: 26px;
font-weight: 600;
text-align: left;
color: $text-color;
padding-top: 43px;
padding-bottom: 43px;
max-width: 100%;
border-bottom: 1px solid gray;
position: relative;
&:hover {
background: #ccc;
&:before {
position: absolute;
width: 1000px;
height: 100%;
content: "";
display: block;
top: 0px;
left: -1000px;
background: red;
}
}
}
}
.right-left-column {
outline: 1px solid gray;
height: 512px;
width: 884px;
background: #fff;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flex;
display: -o-flex;
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
background: #eee;
.object {
outline: 1px solid red;
font-size: 20px;
line-height: 40px;
}
}
}
}
Solution:
&:before {
position: absolute;
width: 100vw;
right: 0;
height: 100%;
content: "";
display: block;
top: 0px;
background: #fff;
z-index: -1;
}
Set the width and left values of your &:before to:
width: calc((100vw - 100%) /2);
left: calc(0 - ((100vw - 100%) /2));
I think that should help, but I don't have access to a screen large enough to test right now so apologies if my calcs are slightly off.