Progress bar under an image slider in pure CSS - html

I would like to make a progress bar under a slider in pure CSS. I have two images in my slider, the bar must be at 50% when the first image is shown and at 100% when the second image is shown.
However I can't display as expected the bar for the second image, the bar won't resize when switching to it (image slider works fine)
Can you help me ?
Thank you !
Audrey
#slider {
position: relative;
width: 100%;
height: 400px;
overflow: hidden;
}
#images_slider {
position: absolute;
top: 0;
left: 0;
margin: 0;
padding: 0;
width: 100%;
height: 400px;
}
#images_slider li {
display: flex;
}
#images_slider img {
width: 100%;
height: 450px;
}
#image_gars:target #image_fille {
left: -150%;
}
#banniere #bouton_prev {
position: absolute;
left : 0;
top: 42%;
border : solid rgba(153,153,153,0.2) 0.1px;
background-color: rgba(153,153,153,0.2);
width: 25px;
height: 50px;
border-top-right-radius: 100px;
border-bottom-right-radius: 100px;
padding-top: 10px;
padding-right: 5px;
z-index: 6;
}
.fa.fa-chevron-left {
position: absolute;
left : 0;
top: 45%;
margin-left: 5px;
color: white;
z-index: 4;
}
#banniere #bouton_next {
position: absolute;
right: 0;
top: 42%;
border : solid rgba(153,153,153,0.2) 0.1px;
background-color: rgba(153,153,153,0.2);
border-top-left-radius: 100px;
border-bottom-left-radius: 100px;
padding-top: 10px;
padding-left: 5px;
width: 25px;
height: 50px;
z-index: 6;
}
.fa.fa-chevron-right {
position: absolute;
right: 0;
top: 45%;
color: white;
margin-right: 5px;
z-index: 4;
}
#ProgressBar {
width: 100%;
height: 5px;
background-color: #A6A6A6;
}
#Progress {
width: 50%;
background-color: rgb(53,151,183);
height: 100%;
}
#bouton_next:target #Progress {
width: 100%;
background-color: blue;
height: 100%;
}
<div id="banniere">
<div id="slider">
<ul id="images_slider">
<li><img src="images/slider/fillepeinture.jpg" alt="Petite fille avec les mains pleine de peinture" id="image_fille"/></li>
<li><img src="images/slider/garconmegaphone.jpg" alt="Petit garçon avec un mégaphone" id="image_gars"/></li>
</ul>
</div>
<i class="fa fa-chevron-right" aria-hidden="true"></i>
<i class="fa fa-chevron-left" aria-hidden="true"></i>
</div>
<div id="ProgressBar">
<div id="Progress"></div>
</div>

I took another stab at this. You were right when you pointed out that the duplicate IDs were a problem. With more than one ID that can be targeted by the anchor, it turns out that neither of them were targeted.
I added a containing div that now carries the triggering ID, and reworked the css for the images and progress divs to use the container's targeted state to switch on and off:
#ProgressBar div {
border: 1px solid black;
color: red;
font-style: italic;
}
#ProgressBar .image_fille {
width: 50%;
}
#ProgressBar .image_gars {
width: 100%;
}
.container .image_fille {
display: block;
}
.container .image_gars {
display: none;
}
.container:target .image_fille {
display: none;
}
.container:target .image_gars {
display: block;
}
<div class="container" id="image_gars">
<div id="banniere">
<img class="image_fille" src="" alt="image fille" />
<img class="image_gars" src="" alt="image gars" />
bouton prev
bouton next
</div>
<div id="ProgressBar">
<div class="image_fille">half progress</div>
<div class="image_gars">full progress</div>
</div>
</div>

Related

Div Element is Spilling of the Page Horizontally While the parent element is not

I have a div on my that contains pieces of information on my webpage. I'm having a problem where when the window gets smaller, part of the div gets cropped off the page.
Notes:
I have in my CSS inside my body element overflow-x: hidden;
The element that is spilling off the page contains a parent element. However, the parent element doesn't spill off the page.
View my code here
https://codepen.io/Tech-World/pen/ExLgNZq
Code added below:
scrollTo (0, 800)
body {
overflow-x: none;
}
.homepage-info {
position: absolute;
top: 1100px;
width: 100vw;
}
.why-heading {
text-align: center;
}
.info-blocks {
background-color: rgb(29, 31, 29);
height: 100px;
padding: 500px;
position: relative;
top: 50px;
padding-bottom: 300px;
max-width: 100%;
}
.info-block {
text-align: center;
background-color: rgb(204, 204, 204);
color: white;
width: 25%;
height: 200px;
padding: 30px;
margin: 50px;
border-radius: 10px;
}
#affordable {
position:absolute;
bottom: 500px;
left: 1245px;
}
#real-code {
position:absolute;
top: 400px;
left: 650px;
}
#in-person {
position:absolute;
bottom: 500px;
left: 40px;
}
#code-line-1 {
color: white;
position: absolute;
bottom: 825px;
left: 43.5%;
}
#code-line-2 {
color: white;
position: absolute;
bottom: 800px;
left: 35.5%;
}
<div class="homepage-info">
<h1 class="why-heading">Scroll down and shrink your window size</h1>
<div class="info-blocks">
<div class="fade-out info-block right-align " id="affordable">
<h2>Salve</h2>
<p>Test</p>
</div>
<div class="fade-out info-block left-align" id="real-code">
<h2>Hola</h2>
<p>Test</p>
</div>
<div class="fade-out info-block right-align" id="in-person">
<h2>Dobro</h2>
<p>Test</p>
</div>
</div>
Check below link for revised code.
https://codepen.io/nandujasthi/pen/zYjKzJz
Left of the div is mentioned in pixel with absolute position of element. Instead you can use the percentages to make it work efficiently in all the devices. Please check the link
body {
overflow-x: none;
}
.homepage-info {
position: absolute;
top: 10%;
width: 100vw;
left: 0;
}
.why-heading {
text-align: center;
}
.info-blocks {
background-color: rgb(29, 31, 29);
height: 100px;
padding: 500px;
position: relative;
top: 5%;
padding-bottom: 300px;
max-width: 100%;
}
.info-block {
text-align: center;
background-color: rgb(204, 204, 204);
color: white;
width: 25%;
height: 200px;
padding: 30px;
margin: 50px;
border-radius: 10px;
}
#affordable {
position:absolute;
top: 5%;
right: 10%;
}
#real-code {
position:absolute;
top: 45%;
left: 33%;
}
#in-person {
position:absolute;
bottom: 500px;
left: 10%;
}
#code-line-1 {
color: white;
position: absolute;
bottom: 825px;
left: 43.5%;
}
#code-line-2 {
color: white;
position: absolute;
bottom: 800px;
left: 35.5%;
}
<div class="homepage-info">
<h1 class="why-heading">Scroll down and shrink your window size</h1>
<div class="info-blocks">
<div class="fade-out info-block right-align " id="affordable">
<h2>Salve</h2>
<p>Test</p>
</div>
<div class="fade-out info-block left-align" id="real-code">
<h2>Hola</h2>
<p>Test</p>
</div>
<div class="fade-out info-block right-align" id="in-person">
<h2>Dobro</h2>
<p>Test</p>
</div>
</div>
</div>

placing a circle on a picture I have in my css

I'm trying to put a circle on the corner of a frame like the picture but only the part of the circle that's inside of the frame can be seen. The part that i marked with x is invisible.
How it looks:
How I want it to look:
My code:
.circle{
height: 150px;
width: 150px;
border-radius: 50%;
background: black;
line-height: 0;
position: absolute;
right:-20px; top:-2px;
z-index: 2;
}
.circle:after {
content: "";
display: block;
padding-bottom: 100%;
position: relative;
}
.circle-txt {
/* (E1) CENTER TEXT IN CIRCLE */
position: absolute;
bottom: 50%;
width: 100%;
text-align: center;
/* (E2) THE FONT - NOT REALLY IMPORTANT */
font-family: "font";
font-size:inherit;
}
:root{
--pic:"M510.295 108.139C571.169 177.774 609.697 279.36 589.662 365.38C570.398 451.399 492.572 521.854 409.352 555.443C326.132 589.031 236.748 586.574 162.775 548.889C88.8013 511.204 30.2391 438.292 8.66355 353.91C-12.1414 268.71 4.81077 171.22 56.438 104.043C107.295 36.8656 193.597 0 278.358 0C363.89 0.819237 448.651 38.5041 510.295 108.139Z"
}
.frame{
padding-right: 1px;
height: 579px;
width: 595px;
clip-path: path(var(--pic));
margin-left: 8%;
margin-bottom: 5%;
position: relative;
z-index: 1;
}
img{
height: 579px;
width: 595px;
}
<div class="frame">
<img src="1.png">
<div class="circle">
<div class="circle-txt">فریلنسینگ چیست؟</div>
</div>
</div>
I would appreciate if anyone can tell me what is that I'm doing wrong.
Check out my solution.
.circle {
height: 150px;
width: 150px;
border-radius: 50%;
background: black;
line-height: 0;
position: absolute;
right: 30px;
top: 38px;
z-index: 2;
}
.wrapp {
height: 579px;
width: 595px;
margin-left: 8%;
margin-bottom: 5%;
position: relative;
}
.frame {
clip-path: path(var(--pic));
}
img {
height: 579px;
width: 595px;
background: red;
}
.circle:after {
content: "";
display: block;
padding-bottom: 100%;
position: relative;
}
.circle-txt {
/* (E1) CENTER TEXT IN CIRCLE */
position: absolute;
bottom: 50%;
width: 100%;
text-align: center;
color:#fff;
/* (E2) THE FONT - NOT REALLY IMPORTANT */
font-family: "font";
font-size:inherit;
}
:root{
--pic:"M510.295 108.139C571.169 177.774 609.697 279.36 589.662 365.38C570.398 451.399 492.572 521.854 409.352 555.443C326.132 589.031 236.748 586.574 162.775 548.889C88.8013 511.204 30.2391 438.292 8.66355 353.91C-12.1414 268.71 4.81077 171.22 56.438 104.043C107.295 36.8656 193.597 0 278.358 0C363.89 0.819237 448.651 38.5041 510.295 108.139Z"
}
<div class="wrapp">
<div class="circle">
<div class="circle-txt">فریلنسینگ چیست؟</div>
</div>
<div class="frame">
<img src="1.png" />
</div>
</div>
From your description and images shared, it seems you maybe using border-radius around the entire set of elements, which is cutting off the smaller top right hand side circle.
Here is a solution you can use.
HTML:
<div class="circle-wrapper">
<div class="big-circle"></div>
<div class="little-circle"></div>
<div class="circle-wrapper">
CSS:
.circle-wrapper { position: relative; width: 24px; height: 24px; }
.big-circle { width: 24px; height: 24px; background: red; border-radius: 24px; }
.little-circle { position: absolute; width: 12px; height: 12px; background: blue; border-radius: 12px; top: -6px; right: -6px; }
Use border-radius to allow overflowing content to be seen, clip-path cuts it out ;) (or use it on img itself if that's good enough)
possible example.
.circle{
height: 150px;
width: 150px;
border-radius: 50%;
background: black;
line-height: 0;
position: absolute;
right:-20px; top:-2px;
z-index: 2;
}
.circle:after {
content: "";
display: block;
padding-bottom: 100%;
position: relative;
}
.circle-txt {
/* (E1) CENTER TEXT IN CIRCLE */
position: absolute;
bottom: 50%;
width: 100%;
text-align: center;
/* (E2) THE FONT - NOT REALLY IMPORTANT */
font-family: "font";
font-size:inherit;
color:hotpink;
}
:root{
--pic:"M510.295 108.139C571.169 177.774 609.697 279.36 589.662 365.38C570.398 451.399 492.572 521.854 409.352 555.443C326.132 589.031 236.748 586.574 162.775 548.889C88.8013 511.204 30.2391 438.292 8.66355 353.91C-12.1414 268.71 4.81077 171.22 56.438 104.043C107.295 36.8656 193.597 0 278.358 0C363.89 0.819237 448.651 38.5041 510.295 108.139Z"
}
.frame{
padding-right: 1px;
height: 579px;
width: 595px;
/*clip-path: path(var(--pic));*/
margin-left: 8%;
margin-bottom: 5%;
position: relative;
z-index: 1;
border-radius:50%;
border:solid;
}
img{
height: 579px;
width: 595px;
border-radius:50%;
background:hotpink;
}
<div class="frame">
<img src="1.png">
<div class="circle">
<div class="circle-txt"> فریلنسینگ چیست؟ </div>
</div>
</div>

With CSS, Position a div (B) below (vertically, not z-index) another div (A) based on div A's height and position

Consider the following jsfiddle:
https://jsfiddle.net/0fwhmhLe/
html markup:
<div class="city-losangeles-bg">
<div class="user-container user-container-losangeles">
<div class="user-pic user-pic-losangeles"></div>
<div class="user-name-container">
<p class="user-name">User Name</p>
<div class="user-name-mask"></div>
</div>
<hr class="underline">
<div class="ellipse-container">
<div class="ellipse ellipse-losangeles-1"></div>
<div class="ellipse ellipse-losangeles-2 ellipse-with-left-margin"></div>
<div class="ellipse ellipse-losangeles-3 ellipse-with-left-margin"></div>
</div>
</div>
<p class="user-text user-text-losangeles">Some text that needs to be below the user-container div, based on the position and height of user-container</p>
</div>
css:
.city-losangeles-bg
{
width: 100%;
height: 1230px;
top: 0px;
background-color: orange;
position: relative;
}
.user-container
{
position: relative;
width: 206px;
height: 192px;
background-color: green;
}
.user-container-losangeles
{
left: 41%;
top: 25px;
}
.user-pic
{
position: relative;
width: 73px;
height: 73px;
left: -36.5px;
margin-left: 50%;
border-radius: 50%;
border: none;
}
.user-pic-losangeles
{
background-color: red;
}
.user-name-mask
{
position: relative;
width: inherit;
height: inherit;
top: 0;
}
.user-name
{
position: relative;
font-family: Ariel;
font-size: 28px;
text-align: center;
width: 100%;
/*top: -6px;*/ /*so text hides properly under color bar reveal animation */
}
.underline
{
position: absolute;
width: 178px;
top: 138px;
left: 14px;
margin-top: 0;
margin-bottom: 0;
}
.ellipse-container
{
position: absolute;
width: 126px;
height: 30px;
top: 162px;
left: 40px;
}
.ellipse
{
position: relative;
width: 30px;
height: 30px;
float: left;
border-radius: 50%;
border: none;
}
.ellipse-with-left-margin
{
margin-left: 18px;
}
.ellipse-losangeles-1
{
background-color: #4574b4;
}
.ellipse-losangeles-2
{
background-color: #71c8ca;
}
.ellipse-losangeles-3
{
background-color: #e6dddd;
}
.user-text
{
position: relative;
margin-top: 0; /* 100 */
font-family: Ariel;
font-size: 26px;
text-align: center;
line-height: 50px;
color: #848484;
}
.user-text-losangeles
{
margin-left: 29%;
width: 50%;
}
I can't figure out how to make the paragraph tag user-text user-text-losangeles always be below the div user-container user-container-losangeles. I thought they should automatically stack and if I changed user-container-losangeles's top property that user-text-losangeles would get bumped down as well.
Someone tell me what obvious mistake I am making please!!
You can use padding-top: 25px; on the container (.city-losangeles-bg) instead of the top:25px; of .user-container-losangeles
https://jsfiddle.net/y8pocwsn/1/
The reason: With position:relative and a topsetting an element is simply moved down from its original position, but the subsequent elements are NOT moved. The space reserved for the element is still the space it would occupy with top: 0 , which is the same as if that element would have position: static

Absolute element not placing over relative element

Within my header, I am trying to place pending-button-notification over theimages-cart image. For some reason, the pending-button-notification div is showing on the left side of the header div.
Does anyone see why this isn't placing correctly?
This is the problematic code:
<div id="pending-order-button">
<a href="pendingOrders.html"><img src="images/cart.png" class="header-buttons" alt="Car">
<div id="pending-button-notification"></div>
</a>
</div>
header {
width: 100%;
max-width: 100%;
height: 100px;
position: relative;
border-bottom: 1px solid #E5E5E5;
}
#header-wrap {
width: 90%;
height: 100%;
margin: auto 5%;
}
#header-logo {
width: 200px;
height: auto;
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.header-buttons {
width: 30px;
height: auto;
float: right;
margin: 30px 40px 0 50px;
cursor: pointer;
}
.header-buttons:first-child {
margin-right: 0;
}
#pending-order-button {
position: relative;
}
#pending-button-notification {
border-radius: 15px;
background: #09afdf;
height: 25px;
width: 25px;
position: absolute;
color: #FFF;
font-size: 1.3rem;
top: 5px;
left: 5px;
text-align: center;
}
<header>
<div id="header-wrap">
Logo
<img src="images/menu.png" class="header-buttons" alt="Pending Orders">
<div id="pending-order-button">
<a href="pendingOrders.html"><img src="images/cart.png" class="header-buttons" alt="Car">
<div id="pending-button-notification"></div>
</a>
</div>
</div>
</header>
It's your float:right on .header-buttons which is causing the problem.
I suggest that you remove that and float the #pending-order-button div instead so that it and all it's content is moved to the right.
#pending-order-button {
position: relative;
float:right;
}

Using CSS to Draw 3 Vertical Lines on an Image

So I'm really new using CSS, I need to add 3 vertical red lines on top of an image, the lines have to split the image in 4 equally sized parts. The size of the image is always 465*346 and the mark up I have so far looks like this
CSS:
.logo-container {
position: relative;
height: 87px;
width: 35%;
margin: 0 auto;
min-width: 144px;
}
.logo {
position: relative;
width: 72px;
height: 87px;
z-index: 2;
}
.logo-line {
position: relative;
display: inline-block;
top: -50%;
width: 20%;
height: 2px;
background: #333;
}
HTML:
<div id="preview-image-wrapper">
<span class="firstOverlayLine" ></span>
<span class="secondOverlayLine"></span>
<span class="thirdOverlayLine"></span>
<img id="mainImage" type="image" class="mainimage" data-bind="attr: {src: SelectedImagePath}" />
</div>
The above is my attempt to modify this example to make it fit my needs, but with no success so far.
The end result should look like:
You can do something raw like this - floating 1px-wide spans over the image, keeping your original HTML:
div {
width: 465px;
position: relative;
}
span {
position: absolute;
display: block;
height: 346px;
width: 1px;
background: red;
}
.firstOverlayLine {
left: 25%;
}
.secondOverlayLine {
left: 50%;
}
.thirdOverlayLine {
left: 75%;
}
<div id="preview-image-wrapper">
<span class="firstOverlayLine"></span>
<span class="secondOverlayLine"></span>
<span class="thirdOverlayLine"></span>
<img src="http://placehold.it/465x346">
</div>
You could use :before and :after :pseudo-elements.
#img {
position: relative;
width: 465px;
height: 346px;
background: url(http://dummyimage.com/465x346/ddd5ed/fff);
border: 1px solid red;
}
#img:before, #img:after {
position: absolute;
content: '';
width: 25%;
height: 100%;
top: 0;
left: 25%;
border-left: 1px solid black;
border-right: 1px solid black;
box-sizing: border-box;
}
#img:after {
left: 75%;
border-right: 0;
}
<div id="img"></div>
Alternative using unordered list:
http://jsfiddle.net/a4q63mwc/
<div id="preview-image-wrapper">
<ul>
<li></li>
<li></li>
<li></li>
</ul>
<img src="http://placehold.it/465x346" />
</div>
div, img {
width: 465px;
height: 346px;
position: relative;
}
ul {
margin:0;
padding:0;
list-style-type: none;
position: absolute;
display: block;
height: 346px;
width:100%;
z-index:200;
overflow:hidden;
}
li {
height:346px;
border-right:1px solid red;
width:25%;
display:inline-block;
margin-right: -4px;
}
For a horizontal line, if someone needs it.
div {
width: 465px;
position: relative;
}
span {
position: absolute;
display: block;
height: 2px;
width: 465px;
background: red;
}
.firstOverlayLine {
top: 50%;
}
<div id="preview-image-wrapper">
<span class="firstOverlayLine"></span>
<img src="http://placehold.it/465x346">
</div>