Carousel indicators WITHOUT bootstrap and WITHOUT any function - html

I've seen a LOT of examples for making carousel indicators for a pictures gallery. But all of them were using bootstrap or radio buttons (for jumping to another pic). I don't want that.
Given the code below, is there a way to show the user which of the 3 pictures is he/she currently viewing? I don't want the user to be able to click the indicator to jump to another picture. I just want to highlight the indicator so he/she knows "ok then, I'm on the second picture".
I want to use this thing ONLY on mobile and tablet, then with media queries I will change it on desktop.
NOTE: I am a beginner, I know how to work with HTML and CSS only...I'm sure there are plenty of ways to do that using JS...but I wouldn't understand them.
Here is the page in question so you can see how it behaves. IMPORTANT: Inspect it with mobile simulator to see the behavior, 'cause the code snippet won't work properly here.
.sezionecane {
margin-top: 1.5em;
}
.nomecane {
text-align: center;
margin-bottom: .5em;
}
.immaginicane {
display: flex;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
scroll-snap-type: x mandatory;
scroll-behavior: smooth;
margin-bottom: 1em;
}
.immaginicane::-webkit-scrollbar {
display: none;
}
.immaginicane > img {
scroll-snap-align: start;
}
<div class="sezionecane">
<h3 class="nomecane">Osso</h3>
<div class="immaginicane">
<img id="foto1" src="cani/foto1.jpg" width="100%" alt="foto1">
<img id="foto2" src="cani/foto2.jpg" width="100%" alt="foto2">
<img id="foto3" src="cani/foto3.jpg" width="100%" alt="foto3">
</div>
<p class="testocane">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi soluta, dolore! Sed aliquid assumenda exercitationem dolores numquam, at rerum quia, ducimus impedit consequuntur! Rem illo debitis beatae quas modi similique nemo, minima atque natus laborum. Aperiam, rerum et nesciunt ullam?</p>
</div>

Not solved (currently). You can click #foto1 and it'll change the color of #foto2 (or #foto3) but not previous element nor what is outside its parent like the dots. Apart of that, it does looks fine in mobile.
The ~.dots#dot-s are probably needed to be placed inside of .immaginicane, but that does’t seems to work.
<style>
.sezionecane{
margin-top: 1.5em;
}
.nomecane{
text-align: center;
margin-bottom: .5em;
}
.immaginicane{
display: flex;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
scroll-snap-type: x mandatory;
scroll-behavior: smooth;
margin-bottom: 1em;
z-index: 10;
}
.immaginicane::-webkit-scrollbar{
display: none;
}
.immaginicane > img{
scroll-snap-align: start;
}
#foto1, #foto2, #foto3{
height: 55vh;width: 100vw;
display: block;position: relative;
}
#foto1::before{
content: "";
height: 0px;width: 0px;
top: 46%;right: 10px;
display: block;position: absolute;
opacity: 0.7;
border: 10px solid transparent;
border-left: 10px solid #72DAFF;
}
#foto1::after{
content: "foto 1";
color: #72DAFF;
top: 6px;left: 12px;
display: block;position: absolute;
opacity: 0.7;
}
#dots{
width: 100%;height: 12px;
display: flex;position: relative;flex-direction: row;
align-items: center;justify-content: center;
z-index: 11;
}
.dot{
background-color: #EEE;
width: 10px;height: 10px;
margin-right: 5px;margin-left: 5px;
display: block;position: relative;
border-radius: 50%;
}
#foto1:hover~#foto2{
background-color: #72DAFF;
}
#foto2:hover~#dot-2{
background-color: #72DAFF;
}
#foto3:hover~#foto-2{
background-color: #72DAFF;
}
</style>
<div class="sezionecane">
<h3 class="nomecane">Osso</h3>
<div class="immaginicane">
<img id="foto1" src="" width="100%" alt="foto1">
<img id="foto2" src="" width="100%" alt="foto2">
<img id="foto3" src="" width="100%" alt="foto3">
</div>
<div id="dots"><div class="dot" id="dot-1"></div><div class="dot" id="dot-2"></div><div class="dot" id="dot-3"></div></div>
<p class="testocane">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi soluta, dolore! Sed aliquid assumenda exercitationem dolores numquam, at rerum quia, ducimus impedit consequuntur! Rem illo debitis beatae quas modi similique nemo, minima atque natus laborum. Aperiam, rerum et nesciunt ullam?</p>
</div>

Related

div table - using summary and details

I made a table with divs, I want to use (summary, details), but when I click on show I want the text to start from the left side under "lala". Please help
Hey, I made a table with divs, I want to use (summary, details), but when I click on show I want the text to start from the left side under "lala". Please help
<div class="div-table dd">
<div class="div-table-row">
<div class="div-table-col">Title</div>
<div class="div-table-col y">Description</div>
<div class="div-table-col"></div>
</div>
<div class="div-table-row">
<div class="div-table-col">lala</div>
<div class="div-table-col x">yy</div>
<details>
<summary></summary>
<div>Lorem ipsum dolor sit amet consectetur adipisicing elit. Corporis id fugit dolorum voluptates saepe, numquam labore quae quia! Laboriosam at natus explicabo minima voluptatibus eligendi neque eum voluptatum aut! Officiis nostrum magni officia minus facilis omnis facere numquam sint porro, nobis aperiam odio commodi, veritatis consequatur, architecto illo accusamus sequi.s</div>
</details>
</div>
</div>
.div-table {
display: table;
width: 90vw;
border: 1px solid #666666;
border-spacing: 5px;
}
.div-table-row {
display: flex;
justify-content: space-between;
margin: 10px;
padding: 10px;
width: auto;
background-color: #ccc;
clear: both;
}
.div-table-col {
float: left;
display: table-column;
width: 33%;
}
.x{
width: 100%;
}
.y{
width: 33%;
}
details{
text-align: right;
}
summary{
padding: 0;
text-align: right;
}
details>summary {
white-space: nowrap;
list-style: none;
}
summary::-webkit-details-marker {
display: none
}
summary::after {
content: 'show ▼';
color: #007bff;
}
details[open] summary:after {
content: "hidden ▲";
}
https://codepen.io/olivier-mazur/pen/XWYdKVw

Is there a way to place text over image without background-image, or position: relative?

My situation is that I don't want it as a background-image because I'm changing the opacity on hover, and so that it didn't affect the text as well I made them separate elements.
However, moving them using position: relative; means that I am left with blank space where their supposed to be in page flow.
Any help would be greatly appreciated.
.flex-container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-evenly;
width: 100%;
}
div {
width: 24%;
min-width: 400px;
height: 25em;
transition: 200ms;
margin: 1rem 0;
}
div.background-img {
width: 100%;
height: 100%;
}
#img-1 {
background-image: url("imgs/tokyo.jpg");
}
/* Later in code */
.background-img:hover {
transition: 200ms;
filter: brightness(50%);
outline: 1px white solid;
outline-offset: -20px;
border-radius: 5%;
}
div .hidden-text {
transition: 200ms;
position: relative;
bottom: 100%;
color: white;
opacity: 0;
pointer-events: none;
}
div:hover .hidden-text {
transition: 200ms;
color: rgb(255, 255, 255, 1);
opacity: 1;
}
<section class="flex-container">
<div>
<h1>Holiday Destinations</h1>
<span>This is a collection of locations that I either would love to visit, or loved visiting.</span>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quaerat totam
eum asperiores assumenda, amet rem molestiae pariatur at nulla sequi
debitis itaque voluptatem modi corrupti fugiat sed quod dolores
perspiciatis maiores in! Tenetur molestiae eum cupiditate obcaecati
consectetur. Culpa consequatur doloribus, non voluptates quia commodi
dolore mollitia cupiditate modi dolorem?
</p>
</div>
<div>
<div class="background-img" id="img-1"></div>
<h2 class="hidden-text">Tokyo - Japan</h2>
<p class="hidden-text">Lorem ipsum dolor sit amet.</p>
</div>
</section>
Website here --> https://dex-hewitt.github.io/holiday-destinations
Thank you!
Also please let me know if I've written question poorly or not included any necessary parts I am new to stackoverflow.
You can approach it this way if you don't want it to be as a background. Let me know
.flex-container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-evenly;
width: 100%;
}
div {
width: 24%;
min-width: 400px;
height: 25em;
transition: 200ms;
margin: 1rem 0;
}
div.background-img {
width: 100%;
height: 100%;
}
div img {
width: 500px;
height: 500px;
object-fit: cover;
}
/* Later in code */
.background-img:hover {
transition: 200ms;
filter: brightness(50%);
outline: 1px white solid;
outline-offset: -20px;
border-radius: 5%;
}
div .hidden-text {
transition: 200ms;
position: relative;
bottom: 100%;
color: white;
opacity: 0;
pointer-events: none;
text-align: center;
}
div:hover .hidden-text {
transition: 200ms;
color: rgb(255, 255, 255, 1);
opacity: 1;
}
<section class="flex-container">
<div>
<h1>Holiday Destinations</h1>
<span>This is a collection of locations that I either would love to visit, or loved visiting.</span>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quaerat totam
eum asperiores assumenda, amet rem molestiae pariatur at nulla sequi
debitis itaque voluptatem modi corrupti fugiat sed quod dolores
perspiciatis maiores in! Tenetur molestiae eum cupiditate obcaecati
consectetur. Culpa consequatur doloribus, non voluptates quia commodi
dolore mollitia cupiditate modi dolorem?
</p>
</div>
<div>
<img class="background-img" src="https://thumbs.dreamstime.com/b/shinjuku-gyoen-national-garden-tokyo-japan-large-park-shibuya-lake-asian-153188061.jpg" >
<h2 class="hidden-text">Tokyo - Japan</h2>
<p class="hidden-text">Lorem ipsum dolor sit amet.</p>
</div>
</section>
Sorry all, a typo mistake on my end. While I thought it was the texts border box causing the blank space, I found it to be a missing "/" symbol on a lower div.

How to make square image container with css grid

I want to make a modal with a image and other elements to the right, something like this:
I tried making the modal content as a grid with two columns, the problems is when I try to adjust the image to fill all the avaiable space in the modal content, it overflows like this:
My css code looks like this:
<div class="modal">
<div class="content">
<div class="frame">
<img src="https://picsum.photos/400" alt="Example">
</div>
<div class="text">
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Quis est mollitia possimus omnis nisi quo
aliquid ad accusantium dignissimos corrupti. Impedit, asperiores magnam corporis iste possimus tempore
quisquam provident dicta. Lorem ipsum dolor sit, amet consectetur adipisicing elit. Quibusdam
consequuntur, incidunt hic dolorum tempora inventore id sint ullam magnam veniam eveniet vitae, harum
dolorem tenetur libero voluptate voluptatibus. Inventore, excepturi!
</div>
</div>
</div>
.modal {
position: fixed;
height: 100%;
width: 100%;
background-color: rgba($color: #000000, $alpha: 0.6);
display: grid;
place-items: center;
}
.content {
background-color: $color-white;
width: 60%;
height: 600px;
border-radius: 5px;
display: grid;
grid-template-columns: auto 300px;
}
.frame > img {
width: 100%;
max-height: 100%;
object-fit: cover;
}
.text {
padding: 2rem 1rem;
}
The modal I tried to do has the problem of the image overflow. I setted the container div to grid with two columns, but the image column overflows the container as we can see in the picture. I want the image to take the space avaiable in the container but maintaining the 1 : 1 aspect ratio, also to be responsive, when the user change the screen size the image always has to maintain the 1:1 aspect ratio and not crop the image.I setted the height as static pixels because I want to add a element with a scrolling bar that otherwise will overflow or expand the container if its height was declared as percentages.
Just specify a max-height to the container(.frame) it will start working fine for 1:1 images because max-height:100% doesn't mean anything if you don't specify a height for its parent
and if you want to work for any ratio then remove the width property from the .frame > img because if you don't specify a width it will adjust itself according to it's height
I think the easiest way would be to use css aspect-ratio like this:
img {
width: 100%;
aspect-ratio: 1;
}
you can read more about it here
I think the problem might be the fact that your image's parent ( .frame ) does not have a set height.Try adding this:
.frame {
height:100%
}
I solved it removing the height of the modal content div. This allow the image to take all the space it needs. For the text to the right to not overgrow the image, what i did was make a div container and inside it a p tag with position absolute and with the widht and height of his parent, but with overflow: scroll. This allowed me to have mi image in 1:1 ratio taking all the space it needs in the card but without the text overflowing things. Here is how I did it.
.modal {
position: fixed;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.6);
display: grid;
place-items: center;
}
.container {
width: 60%;
display: grid;
grid-template-columns: 1fr 30%;
background-color: #f4f4ed;
}
.frame {
width: 100%;
height: 100%;
}
.frame img {
width: 100%;
height: 100%;
object-fit: cover;
}
.content {
display: flex;
flex-direction: column;
align-items: center;
padding: 2em 0.8em;
}
.content h5 {
font-size: 1.4rem;
font-weight: 600;
color: #00f0b5;
}
.text {
flex-grow: 1;
position: relative;
height: 100%;
width: 100%;
overflow-y: scroll;
}
.text p {
font-size: 0.8rem;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.actions {
width: 100%;
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 0.5rem;
}
.actions button {
font-family: "Roboto Condensed", sans-serif;
font-weight: 600;
text-transform: uppercase;
border: none;
outline: none;
background-color: #00f0b5;
padding: 0.2em 0;
cursor: pointer;
font-size: 0.5rem;
}
body {
font-size: 62.5%;
box-sizing: border-box;
}
h5{
margin: 0;
line-height: 1;
}
<div class="modal">
<div class="container">
<div class="frame">
<img src="https://picsum.photos/800" alt="Some lorem picsum">
</div>
<div class="content">
<h5>Title</h5>
<div class="text">
<p>
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Laborum placeat sed voluptatem optio esse facere accusamus tempore, provident dolorem nemo rerum sit accusantium labore quae eveniet ea aliquam. Ipsa, aliquam? Lorem ipsum dolor sit amet consectetur,
adipisicing elit. Laborum placeat sed voluptatem optio esse facere accusamus tempore, provident dolorem nemo rerum sit accusantium labore quae eveniet ea aliquam. Ipsa, aliquam? Lorem ipsum dolor sit amet consectetur, adipisicing elit. Laborum
placeat sed voluptatem optio esse facere accusamus tempore, provident dolorem nemo rerum sit accusantium labore quae eveniet ea aliquam. Ipsa, aliquam?
</p>
</div>
<div class="actions">
<button>Accept</button>
<button>Cancel</button>
</div>
</div>
</div>
</div>

How to remove space between div elements? [duplicate]

This question already has answers here:
CSS margin terror; Margin adds space outside parent element [duplicate]
(7 answers)
Closed 2 years ago.
I have two div elements and I want to remove the space between them, which is filled with the background color at the moment. This is what it looks like. I want to remove the space between the green section and where the background image ends for the first div element. Here is the HTML for the page:
<body style="background-color: #c5ffff">
<div class="main-search hero-image">
Log Out
<div class="welcome-text">
<div class="title">Welcome to Ripple.</div>
<div class="content">Lorem ipsum dolor sit amet, consectetur adipisicing elit. A aliquam commodi doloremque esse itaque iusto, labore laborum maxime odio, quidem quos, repellat rerum? Ab, asperiores aspernatur assumenda atque distinctio dolor dolore eveniet facilis, id illo ipsa ipsam minus nemo nobis porro quam quia quibusdam quis ratione rerum soluta suscipit temporibus vel vitae voluptate. Accusamus dignissimos ea esse expedita itaque mollitia nobis, numquam odio, quaerat qui vel voluptatibus?</div>
<button class="search_button" >Search for a location</button>
<button class="search_button">Search for a song</button>
</div>
</div>
<div class="main-left">
<div class="title">Collections Near Me</div>
<div>
</div>
</body>
And the CSS:
.main-left {
vertical-align: top;
margin-top: 0;
margin-left: 0;
position: relative;
background-color: #85dcba;
text-align: left;
width: 100%;
float: top;
left: 50%;
transform: translate(-50%);
}
.main-search {
vertical-align: top;
background-color: #d2fdff;
text-align: left;
margin: 0;
padding-top: 2em;
position: relative;
top: 0;
width: 100%;
left: 50%;
transform: translate(-50%);
}
.hero-image {
background-image: url("main_background.jpg");
background-size: cover;
background-repeat: no-repeat;
}
.title {
color: black;
font-family: Roboto, sans-serif;
font-size: 3em;
margin-top: 0.5em;
margin-left: 10px;
margin-bottom: 0.5em;
}
.content {
color: black;
font-family: Roboto, sans-serif;
font-size: 1em;
margin: 1em;
}
.welcome-text {
top: 5%;
left: 5%;
max-width: 35%;
}
There is a gap because div is block element, if you want to remove the gap between div use display: inline-block to remove it.
body > div { display: inline-block; }
This will display an element as an inline-level block container. Please refer to CSS Display
You could try setting the margin values of the elements manually. I see you've set the padding- Which refers to the internal distance of contents to edge, but not the margin- which refers to the distance between seperate elements.
Also, nice looking design so far!
Display flex has a nifty way of removing undesirable whitespace from the html
So place flex on the wrapper of these elements, in this case the body tag
css
body {
display: flex;
flex-direction: column;
}
Set margin-top of the .title to zero and for space between the .main-search and .title, give padding-bottom to .main-search as well. Below is how it will look like:
body{
background-color: #c5ffff;
}
.main-left{
vertical-align: top;
margin-top: 0;
margin-left: 0;
position: relative;
background-color: #85dcba;
text-align: left;
width: 100%;
float: top;
left: 50%;
transform: translate(-50%);
}
.main-search{
vertical-align: top;
background-color: #d2fdff;
text-align: left;
margin: 0;
padding: 2em 0;
position: relative;
top: 0;
width: 100%;
left: 50%;
transform: translate(-50%);
}
.hero-image{
background-image: url("https://picsum.photos/500/500");
background-size: cover;
background-repeat: no-repeat;
}
.title{
color: black;
font-family: Roboto, sans-serif;
font-size: 3em;
margin-top: 0;
margin-left: 10px;
margin-bottom: 0.5em;
}
.content{
color: black;
font-family: Roboto, sans-serif;
font-size: 1em;
margin: 1em;
}
.welcome-text{
top: 5%;
left: 5%;
max-width: 35%;
}
<div class="main-search hero-image">
Log Out
<div class="welcome-text">
<div class="title">Welcome to Ripple.</div>
<div class="content">Lorem ipsum dolor sit amet, consectetur adipisicing elit. A aliquam commodi doloremque esse itaque iusto, labore laborum maxime odio, quidem quos, repellat rerum? Ab, asperiores aspernatur assumenda atque distinctio dolor dolore eveniet facilis, id illo ipsa ipsam minus nemo nobis porro quam quia quibusdam quis ratione rerum soluta suscipit temporibus vel vitae voluptate. Accusamus dignissimos ea esse expedita itaque mollitia nobis, numquam odio, quaerat qui vel voluptatibus?</div>
<button class="search_button" >Search for a location</button>
<button class="search_button">Search for a song</button>
</div>
</div>
<div class="main-left">
<div class="title">Collections Near Me</div>
<div>
remove margin-top:0.5em; on your title class.
.title {
color: black;
font-family: Roboto, sans-serif;
font-size: 3em;
margin-top: 0.5em; <-- REMOVE
margin-left: 10px;
margin-bottom: 0.5em;

Inside border of image

I have some problem with creating inside border of image. Tried to do it with border, outline and box-shadow but didn't get the result.
HTML:
<div class="item">
<img src="https://i.ytimg.com/vi/vsZDSXlHqI4/maxresdefault.jpg" alt="">
<h3>Title</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illo blanditiis, distinctio. Odio eveniet vel nobis, consequuntur atque, dolorum debitis quae nesciunt esse quasi beatae, odit repudiandae dolore animi delectus ad nostrum, quas maiores hic labore?
Nisi, expedita sint, qui ullam itaque natus optio error accusantium placeat, culpa reiciendis, quos tempora.</p>
<button>Some action</button>
</div>
CSS:
div.item:hover {
//some code
img {
border-bottom: 5px solid #8cc34b;
margin-bottom: -5px;
}
}
My fiddle: JSFiddle
Here I got the outside border but I want to get inside border of image.
Thanks for help.
Wrap your img in div, and on hover use :after pseudo-element:
div.item {
min-height: 300px;
overflow: auto;
width: 300px;
background-color: white;
border: 2px solid #8cc34b;
border-radius: 5px;
text-align: center;
box-sizing: border-box;
-webkit-box-sizing: border-box;
}
div.item img {
width: 100%;
display: block;
}
div.item p {
text-align: left;
padding-left: 10px;
padding-right: 10px;
}
div.item button {
height: 35px;
width: 120px;
margin: 0 auto;
margin-bottom: 20px;
}
div.item .img-container {
position: relative;
}
div.item:hover h3 {
color: #8cc34b;
}
div.item:hover .img-container:after {
content: '';
position: absolute;
left: 0;
bottom: 0;
height: 5px;
width: 100%;
background-color: #8cc34b;
}
<div class="item">
<div class="img-container">
<img src="https://i.ytimg.com/vi/vsZDSXlHqI4/maxresdefault.jpg" alt="">
</div>
<h3>Title</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illo blanditiis, distinctio. Odio eveniet vel nobis, consequuntur atque, dolorum debitis quae nesciunt esse quasi beatae, odit repudiandae dolore animi delectus ad nostrum, quas maiores hic labore?
Nisi, expedita sint, qui ullam itaque natus optio error accusantium placeat, culpa reiciendis, quos tempora.</p>
<button>Some action</button>
</div>
I also added display: block on img, because inline img creates extra whitespace below.
Another answer:
To create a color bar like in the image you liked to, I wrapped your image in a DIV with class x and added the following CSS (including a pseudo element):
img {
width: 100%;
}
.x {
display: block;
position: relative;
}
.x:before {
content: '';
position: absolute;
z-index: -1;
bottom: 7px;
left: 0;
right: 0;
height: 5px;
background-color: #8cc34b;
}
Instead of a hover rule for the image, I just make the x DIV visible by changing its z-index:
div.item:hover {
h3 {
color: #8cc34b;
}
.x:before {
z-index: 1;
}
}
Adjust the bottom setting as desired to move it up or down:
https://jsfiddle.net/9wLx9p0f/5/
We can simply do this with outline-offset property:
outline: 1px solid #fff;
outline-offset: -10px;
Try this in the div you wants, if it works for you.