Span tooltip is getting hidden - html

I have an image container with images and text below it. Since the title of image is long, i used text-overflow property to hide long text and used a tooltip for displaying the long text of title when i hover over the title.
I was facing an issue wheerin when i scroll the image, the tooltip would remain fixed so i asked it in herelink
HTML code:
<div className="image-container">
<center>
<div className='container p-1'>
<div className="image">
<img style={{ width: 200, height: 200 }} src="http://ecx.images-amazon.com/images/I/51PhUckHB3L.jpg"></img>
<div className="caption">Product Title<br></br>
<small className='ellipsis'>Electrolux EENB54EB Ultraenergica Classic Aspirapolvere</small>
<span className="tooltiptext">Electrolux EENB54EB Ultraenergica Classic Aspirapolvere</span>
</div>
</div>
</div>
<div className='container p-1'>
<div className="image">
<img style={{ width: 200, height: 200 }} src="http://ecx.images-amazon.com/images/I/518Se4188mL.jpg"></img>
<div className="caption">Left Product Title<br></br>
<small className='ellipsis'>Amore Legno Sforza segnalibro, segnalibro particolare, segnalibro legno, segnalibro laurea, idea regalo, segnalibri regali, regali originali per amiche, portafortuna da regalare, made in Italy</small>
<span className="tooltiptext">Amore Legno Sforza segnalibro, segnalibro particolare, segnalibro legno, segnalibro laurea, idea regalo, segnalibri regali, regali originali per amiche, portafortuna da regalare, made in Italy</span>
</div>
</div>
</div>
<div className='container p-1'>
<div className="image">
<img style={{ width: 200, height: 200 }} src="http://ecx.images-amazon.com/images/I/518Se4188mL.jpg"></img>
<div className="caption">Right Product Title<br></br>
<small className='ellipsis'>Amore Legno Sforza segnalibro, segnalibro particolare, segnalibro legno, segnalibro laurea, idea regalo, segnalibri regali, regali originali per amiche, portafortuna da regalare, made in Italy</small>
<span className="tooltiptext">Third Legno Sforza segnalibro, segnalibro particolare, segnalibro legno, segnalibro laurea, idea regalo, segnalibri regali, regali originali per amiche, portafortuna da regalare, made in Italy</span>
</div>
</div>
</div>
</center>
</div>
CSS code:
title {
font-size: 42px;
}
figure figcaption {
border: 1px dotted gray;
text-align: center;
}
.container {
margin: 10px;
display: inline-block;
justify-content: center;
width: 50%;
flex-direction: column;
border: 1px solid black;
}
.caption{
justify-content: center;
border-top: 1px solid black;
}
.image{
width: 100%;
vertical-align: middle;
}
.image-container {
position: relative;
vertical-align: middle;
display: inline-block;
white-space: nowrap;
/* overflow-x: auto; */
overflow-y: hidden;
width: 100%;
}
.details{
background-color: white;
position: relative;
overflow: scroll;
box-sizing: border-box;
height: 100vh;
}
.ellipsis {
display: block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
padding:.5rem 1rem;
cursor: pointer;
}
.ellipsis:focus .ellipsis:hover{
color: red;
}
.box{
border-top: 1px solid black;
}
.tooltiptext{
position:absolute;
z-index: 999;
/* top:105%; */
/* left:0%; */
/* right: 0; */
/*op: 105%;
left: 0%;*/
transform: translateY(0%);
background-color: #000;
border-radius: 7px;
color: #fff;
font-size: 15px;
line-height: 20px;
/*padding: 10px 5px;*/
display: block;
width: 200px;
word-wrap: break-word;
white-space: normal;
text-align: center;
visibility: hidden;
opacity: 0;
transition: opacity 0.5s ease;
}
.ellipsis:hover+.tooltiptext{
visibility: visible;
opacity: 1;
}
Suggestion was provided to add .image-container{ position: relative;} and .tooltiptext{position: absolute;}
I did the above change but after that though the tooltip is relative, the tooltip text is getting hidden :(
I tried adding z-index:1 and z-index:999 in the .tooltiptext but still same issue. Can someone help me achieve this so that tooltip is above all and relative to the images scroll?

Related

Span tooltip position remains fixed when i slide the image to another position and hover over it

I have an image container with images and text below it.
Since the title of image is long, i used text-overflow property to hide long text and used a tooltip for displaying the long text of title when i hover over the title. This thing is working fine. see here:
[
But issue i am facing here is this is an image slider and when i slide the image and hover over the image, the tooltip still remains fixed in same position for each image and it seems like its shown for another image. Basically I want the tooltip to be relative to the same image. See here i scrolled left and hovered over first title and it shows under second title hoover
Basically i want the hover to be relative to the title when scrolled. I tried adding position:relative in tooltiptext but the boxes were disrupted like this:
Please can someone help me fix this? I want the title to be visible when hovered as image1 but when i scroll it should move along with he image.
HTML code:
<div className="image-container">
<center>
<div className='container p-1'>
<div className="image">
<img style={{ width: 200, height: 200 }} src="http://ecx.images-amazon.com/images/I/51PhUckHB3L.jpg"></img>
<div className="caption">Product Title<br></br>
<small className='ellipsis'>Electrolux EENB54EB Ultraenergica Classic Aspirapolvere</small>
<span className="tooltiptext">Electrolux EENB54EB Ultraenergica Classic Aspirapolvere</span>
</div>
</div>
</div>
<div className='container p-1'>
<div className="image">
<img style={{ width: 200, height: 200 }} src="http://ecx.images-amazon.com/images/I/518Se4188mL.jpg"></img>
<div className="caption">Left Product Title<br></br>
<small className='ellipsis'>Amore Legno Sforza segnalibro, segnalibro particolare, segnalibro legno, segnalibro laurea, idea regalo, segnalibri regali, regali originali per amiche, portafortuna da regalare, made in Italy</small>
<span className="tooltiptext">Amore Legno Sforza segnalibro, segnalibro particolare, segnalibro legno, segnalibro laurea, idea regalo, segnalibri regali, regali originali per amiche, portafortuna da regalare, made in Italy</span>
</div>
</div>
</div>
<div className='container p-1'>
<div className="image">
<img style={{ width: 200, height: 200 }} src="http://ecx.images-amazon.com/images/I/518Se4188mL.jpg"></img>
<div className="caption">Right Product Title<br></br>
<small className='ellipsis'>Amore Legno Sforza segnalibro, segnalibro particolare, segnalibro legno, segnalibro laurea, idea regalo, segnalibri regali, regali originali per amiche, portafortuna da regalare, made in Italy</small>
<span className="tooltiptext">Third Legno Sforza segnalibro, segnalibro particolare, segnalibro legno, segnalibro laurea, idea regalo, segnalibri regali, regali originali per amiche, portafortuna da regalare, made in Italy</span>
</div>
</div>
</div>
</center>
</div>
CSS code:
.container {
margin: 10px;
display: inline-block;
justify-content: center;
width: 50%;
flex-direction: column;
border: 1px solid black;
}
.caption{
justify-content: center;
border-top: 1px solid black;
}
.image{
width: 100%;
vertical-align: middle;
}
.image-container {
vertical-align: middle;
display: inline-block;
white-space: nowrap;
/* overflow-x: auto; */
overflow-y: hidden;
width: 100%;
}
.details{
background-color: white;
position: relative;
overflow: scroll;
box-sizing: border-box;
height: 100vh;
}
.ellipsis {
position: relative;
display: block;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
padding:.5rem 1rem;
cursor: pointer;
}
.ellipsis:focus .ellipsis:hover{
color: red;
}
.box{
border-top: 1px solid black;
}
.tooltiptext{
position: relative;
/* top:105%; */
/* left:0%; */
/* right: 0; */
z-index: 1;
/*op: 105%;
left: 0%;*/
transform: translateY(0%);
background-color: #000;
border-radius: 7px;
color: #fff;
font-size: 15px;
line-height: 20px;
/*padding: 10px 5px;*/
display: block;
width: 200px;
word-wrap: break-word;
white-space: normal;
text-align: center;
visibility: hidden;
opacity: 0;
transition: opacity 0.5s ease;
overflow: scroll;
}
.ellipsis:hover+.tooltiptext{
visibility: visible;
opacity: 1;
}
Update
Update after Anil Kumar's suggestion in comment of adding { position: relative;} in image container. The tooltip moves with scroll but is still getting hidden. See image:
Think we are close, need help
I have tried to update your code with few html and css changes. Check will this work for you.
.image-container {
overflow-y: hidden;
width: 100%;
}
.wrapper {
width: 100%;
display: flex;
flex-direction: row;
}
.container {
margin: 10px;
width: 33%;
border: 1px solid black;
position: relative;
display: flex;
flex-direction: column;
}
.caption {
position: relative;
text-align: center;
border-top: 1px solid black;
}
.image{
position: relative;
}
img {
position: relative;
}
.ellipsis {
display: block;
position: relative;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
padding: .5rem 1rem;
}
.tooltiptext {
visibility: hidden;
display: none;
opacity: 0;
transition: opacity 0.5s ease;
}
.ellipsis:hover {
cursor: pointer;
}
.ellipsis:hover+.tooltiptext {
visibility: visible;
display: block;
opacity: 1;
position: absolute;
bottom: 0;
background-color: #000;
border-radius: 7px;
color: #fff;
font-size: 15px;
line-height: 20px;
width: 90%;
padding: 10px;
pointer-events: none;
}
<div class="image-container">
<div class="wrapper">
<div class='container p-1'>
<div class="image">
<img style='width: 100%; height: 200px;' src="http://ecx.images-amazon.com/images/I/518Se4188mL.jpg">
<div class="caption">Product Title</div>
<small class='ellipsis'>Electrolux EENB54EB Ultraenergica Classic Aspirapolvere</small>
<span class="tooltiptext">Electrolux EENB54EB Ultraenergica Classic Aspirapolvere</span>
</div>
</div>
<div class='container p-1'>
<div class="image">
<img style='width: 100%; height: 200px;' src="http://ecx.images-amazon.com/images/I/518Se4188mL.jpg">
<div class="caption">Left Product Title</div>
<small class='ellipsis'>Amore Legno Sforza segnalibro, segnalibro particolare, segnalibro legno, segnalibro laurea, idea regalo, segnalibri regali, regali originali per amiche, portafortuna da regalare, made in Italy</small>
<span class="tooltiptext">Amore Legno Sforza segnalibro, segnalibro particolare, segnalibro legno, segnalibro laurea, idea regalo, segnalibri regali, regali originali per amiche, portafortuna da regalare, made in Italy</span>
</div>
</div>
<div class='container p-1'>
<div class="image">
<img style='width: 100%; height: 200px;' src="http://ecx.images-amazon.com/images/I/518Se4188mL.jpg">
<div class="caption">Right Product Title</div>
<small class='ellipsis'>Amore Legno Sforza segnalibro, segnalibro particolare, segnalibro legno, segnalibro laurea, idea regalo, segnalibri regali, regali originali per amiche, portafortuna da regalare, made in Italy</small>
<span class="tooltiptext">Third Legno Sforza segnalibro, segnalibro particolare, segnalibro legno, segnalibro laurea, idea regalo, segnalibri regali, regali originali per amiche, portafortuna da regalare, made in Italy</span>
</div>
</div>
</div>
</div>

Want to make my tooltips appear just below the component and not overlapping it

I want my tooltip to appear just below my text of the image from image slider and not overlap the text or get hidden.
I have tried multiple things but i end up with tooltip getting hidden as follows: or if i remove the position:relative it does not slide with image and remains fixed or goes outside for last element
Html code:
<!DOCTYPE html>
<html>
<head>
<title>Image slider</title>
<link rel="stylesheet" type="text/css" href="style7.css">
</head>
<body>
<div class="image-container">
<center>
<div class="image">
<div class="image-box"><img class="image-cont" src=""></img></div>
<div class="text-box">
<p>Product title</p>
<span id="tooltiptext">Electrolux EENB54EB Ultraenergica Classic Aspirapolvere</span>
<p class="title">Electrolux EENB54EB Ultraenergica Classic Aspirapolvere</p>
</div>
</div>
<div class="image">
<div class="image-box"><img class="image-cont" src="http://ecx.images-amazon.com/images/I/51PhUckHB3L.jpg"></img></div>
<div class="text-box">
<p>Product title</p>
<span id="tooltiptext">WIFI smart ventil, smart vattenventil Automatisk manuell koppling för jordbevattningsrör</span>
<p>Curtain</p>
</div>
</div>
<div class="image">
<div class="image-box"><img class="image-cont" src="http://ecx.images-amazon.com/images/I/518Se4188mL.jpg"></img></div>
<div class="text-box">
<p>Product title</p>
<span id="tooltiptext">Salt Paprika Green Pepper Lovage Root Onion Garlic Savory Rosemary Sweet Basil Coriander Seeds Asafoetida Fenugreek Kycklingkrydda Ekologisk - Söt Kycklinggrillkrydda. Karaokemaskin med 2 trådlösa mikrofoner, bärbar karaokehögtalare Bluetooth-sång PA-system för vuxna och kit, karaokemikrofonuppsättning med stöd för USB TF AUX för hemmafest, vår dörr, julklappar</span>
<p>Curtain</p>
</div>
</div>
<div class="image">
<div class="image-box"><img class="image-cont" src="http://ecx.images-amazon.com/images/I/51PhUckHB3L.jpg"></img></div>
<div class="text-box">
<p>Product title</p>
<span id="tooltiptext">Electrolux EENB54EB Ultraenergica Classic Aspirapolvere</span>
<p>Curtain</p>
</div>
</div>
</div>
</center>
</body>
</html>
Css code:
.image-container {
vertical-align: middle;
display: inline-block;
white-space: nowrap;
overflow-x: auto;
overflow-y: hidden;
width: 50%;
}
.image {
height: 200px;
width: 200px;
font-size: 25px;
margin: 10px;
display: inline-block;
line-height: 100px;
border: 2px solid #ccc;
}
.image-box{
height:150px;
width: 200px;
background: green;
}
.image-cont{
height:150px;
width: 200px;
}
.text-box{
position: relative;
padding:0;
height: 50px;
width: 200px;
font-size: 12px;
line-height: 5px;
border-top: 2px solid #ccc;
overflow: hidden;
text-overflow: ellipsis;
cursor: pointer
}
#tooltiptext{
position: absolute;
/*transform: translateX(-50%);*/
/*transform: translateY(20%);*/
/*transform: translateY(100%);*/
z-index: 2;
top: 105%;
left:0;
/*bottom:105%;*/
background-color: #000;
border-radius: 7px;
color: #fff;
font-size: 15px;
line-height: 20px;
/*padding: 10px 5px;*/
display: block;
width: 200px;
word-wrap: break-word;
white-space: normal;
text-align: center;
visibility: hidden;
opacity: 0;
transition: opacity 0.5s ease;
}
/*#tooltiptext::before{
content: "";
position: absolute;
left: 50%;
top: 100%;
transform: translateX(-50%);
transform: translateY(-50%);
border: 15px solid;
border-color: #0000 #0000 #000 #0000;
}*/
.text-box:hover #tooltiptext{
visibility: visible;
opacity: 1;
}
Expectation: I want my tooltip to be visible entirely and just little below the element when i hover over text-box. It should not be fixed at a position as this is an image slider. Can someone help?

Prevent text from moving when resizing css

With a colleague of mine, we wanted to run a behavioural experiment that involve a fake purchase of virtual goods on a shop webpage. We designed the experiment on OTree (so on Python), but we needed Django and especially some html/css code to correctly place the images and texts on the webpage.
We managed to place the images and text as we wanted, to get something like that (the blue squares are just placeholders for the images):
The problem is that as soon as we change the window size, all the images and text just move on their own.
Here's a part of the code (not including everything because for now, we're just trying to get first the text in place and to understand the logic of it).
Here's the CSS:
<style>
body {
background-image: url('https://i.imgur.com/lVtlHWx.png');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100% 100%;
}
</style>
and the HTML:
<div style="top: 99px; left: 99px;position: absolute; z-index: 1;visibility: visible;">
<h1 style="position: relative; color: #f0f0f0; font-family: Papyrus,monospace;">Welcome to the shop</h1>
<h3 style="position: relative;color: #f0f0f0; font-family: Papyrus,monospace;">Round 1/10</h3>
<p style="position: relative;top:9.5cm; left:6.5cm; color: #f0f0f0; font-family: Papyrus,monospace;font-size:25px;">5 Rubis</p>
<p style="position: relative;top:9.5cm; left:18cm; color: #f0f0f0; font-family: Papyrus,monospace;font-size:25px;">15 Rubis</p>
<p style="position: relative;top:9.5cm; left:29.5cm; color: #f0f0f0; font-family: Papyrus,monospace;font-size:25px;">25 Rubis</p>
<p style="position: relative;top:9.5cm; left:41cm; color: #f0f0f0; font-family: Papyrus,monospace;font-size:25px;">50 Rubis</p>
<p style="position: relative;top:16cm; left:6.5cm; color: #f0f0f0; font-family: Papyrus,monospace;font-size:25px;">5 Rubis</p>
<p style="position: relative;top:9.5cm; left:18cm; color: #f0f0f0; font-family: Papyrus,monospace;font-size:25px;">15 Rubis</p>
<p style="position: relative;top:9.5cm; left:29.5cm; color: #f0f0f0; font-family: Papyrus,monospace;font-size:25px;">25 Rubis</p>
<p style="position: relative;top:9.5cm; left:41cm; color: #f0f0f0; font-family: Papyrus,monospace;font-size:25px;">50 Rubis</p>
We're complete beginners in HTML/CSS and I think we bite more than we could chew. I followed and tried some answers but nothing really helped to resize every element with respect to the window size. Perhaps it is due to positioning the text? I still struggle to really understand how css places elements when their position are absolute or relative. We are in dire need of help on this matter, and would be immensely grateful if someone could solve our issue.
This is a typical case where using a table or better, CSS grid positioning would save you a lot of headaches.
Positioning according to measurements on your background image gives the following:
:root {
--display-scale: .5;
}
body {
padding: 10px;
background: black;
overflow: hidden; /* disable scrolling */
}
.wrapper {
transform: scale(var(--display-scale));
-webkit-transform: scale(var(--display-scale));
transform-origin: 0 0;
width: 1884px;
height: 1076px;
background: url('https://i.imgur.com/lVtlHWx.png') no-repeat;
position: relative;
font-family: Papyrus, monospace;
color: #f0f0f0;
}
.wrapper * {
box-sizing: border-box;
}
.wrapper h1 {
position: absolute;
padding: 0;
top: 10px;
left: 10px;
font-size: 48px;
}
.wrapper h3 {
position: absolute;
padding: 0;
top: 10px;
right: 10px;
font-size: 36px;
}
.wrapper .wallet {
position: absolute;
top: 42px;
height: 46px;
left: 720px;
right: 682px;
font-size: 36px;
display: flex;
align-items: center;
justify-content: center;
}
.wrapper .my-grid {
position: absolute;
/*background: #ff000055;*/
top: 228px;
left: 110px;
right: 82px;
bottom: 82px;
padding: 0;
column-gap: 38px;
display: grid;
grid-template-columns: 384px 402px 406px 1fr;
grid-template-rows: 196px 50px 202px 50px 202px 50px;
grid-auto-flow: column;
}
.my-grid .prod-image {
/*background: #00ff0055;*/
display: flex;
align-items: center;
justify-content: center;
}
.my-grid img {
display: block;
width: 180px;
height: 130px;
background: #5555ff;
outline: 5px solid black;
}
.my-grid .price {
/*background: #0000ff55;*/
font-size: 24px;
margin 0;
padding: 0;
display: flex;
align-items: center;
justify-content: center;
}
<div class="wrapper">
<h1>Welcome to the shop</h1>
<h3>Round 1/10</h3>
<p class="wallet">You have 1000 tokens</p>
<div class="my-grid">
<div class="prod-image"><img class="pic" /></div>
<p class="price">5 Rubis</p>
<div class="prod-image"><img class="pic" /></div>
<p class="price">15 Rubis</p>
<div class="prod-image"><img class="pic" /></div>
<p class="price">25 Rubis</p>
<div class="prod-image"><img class="pic" /></div>
<p class="price">50 Rubis</p>
<div class="prod-image"><img class="pic" /></div>
<p class="price">5 Rubis</p>
<div class="prod-image"><img class="pic" /></div>
<p class="price">15 Rubis</p>
<div class="prod-image"><img class="pic" /></div>
<p class="price">25 Rubis</p>
<div class="prod-image"><img class="pic" /></div>
<p class="price">50 Rubis</p>
<div class="prod-image"><img class="pic" /></div>
<p class="price">50 Rubis</p>
<div class="prod-image"><img class="pic" /></div>
<p class="price">50 Rubis</p>
<div class="prod-image"><img class="pic" /></div>
<p class="price">50 Rubis</p>
<div class="prod-image"><img class="pic" /></div>
<p class="price">50 Rubis</p>
</div>
</div>
Use the --display-scale: .5 variable to adjust display size
You can achieve your desired results with css Grid and Flexbox.
This page content:
<body>
<div id="head">
<h1>Welcome to the shop</h1>
<h3>Round 1/10</h3>
</div>
<div id="labels_container">
<div class="item"><p class="label">5 Rubis</p></div>
<div class="item"><p class="label">15 Rubis</p></div>
<div class="item"><p class="label">25 Rubis</p></div>
<div class="item"><p class="label">50 Rubis</p></div>
<div class="item"><p class="label">5 Rubis</p></div>
<div class="item"><p class="label">15 Rubis</p></div>
<div class="item"><p class="label">25 Rubis</p></div>
<div class="item"><p class="label">50 Rubis</p></div>
<div class="item"><p class="label">5 Rubis</p></div>
<div class="item"><p class="label">15 Rubis</p></div>
<div class="item"><p class="label">25 Rubis</p></div>
<div class="item"><p class="label">50 Rubis</p></div>
</div>
</body>
With this css styling:
body {
background-image: url('./lVtlHWx.png');
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100% 100%;
display: grid;
grid-template-rows: [gstart]1fr[gmid] 5fr[gend];
height: 100vh;
width: 100vw;
}
#head {
grid-row: gstart / gmid;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
#head * {
margin: 0;
}
#labels_container {
grid-row: gmid / gend;
margin-top: 3vh;
margin-left: 5vw;
margin-right: 7vw;
margin-bottom: 9.5vh;
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: repeat(3, 1fr);
column-gap: 2.5%;
}
.item .label {
margin: 0;
margin-bottom: 1vh;
}
* {
color: #f0f0f0;
font-family: Papyrus, monospace;
}
h1, h3 {
position: relative;
}
.item {
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-end;
}
.label {
font-size: 25px;
}
should do what you want.
Note: You might also find it beneficial to make the interface a div in your page with a constant aspect ratio, because you have an image as the backdrop for the entire interface. Having this image deform makes styling the page awkward. That being said, the styles above should work with your current setup.
I couldn't resist, here is what you should really do: abandon your backdrop that constrains layout, and use a real HTML layout instead, with textures to help achieving the effect you want.
This snippet should be viewed in full page mode
:root {
--iron-texture: url('https://www.outworldz.com/SeamlessTextures/master/Metal/iron_diffuse.png');
--wood-texture: url('https://images.designtrends.com/wp-content/uploads/2015/12/22092207/Seamless-Wooden-Floor-Texture.jpg?width=600');
}
html { padding: 0; margin: 0; height: 100%;}
body {
box-sizing: border-box;
padding: 1rem;
margin: 0;
min-height: 100%;
background: black;
color: white;
font-family: Papyrus, monospace;
font-size: 16px;
display: flex;
align-items: center;
justify-content: center;
}
.shop {
box-sizing: border-box;
width: 100%;
max-width: 1200px;
background: var(--wood-texture);
background-size: 30%;
color: #ccc;
padding: 1rem;
}
.shop header {
position: relative;
display: flex;
flex-direction: column;
gap: 1em;
}
.shop h1,
.shop p {
padding: 0;
margin: 0;
}
.shop h1 {
font-size: 32px;
}
.shop .round {
position: absolute;
top: 0;
right: 0;
font-size: 28px;
}
.iron-style {
background: var(--iron-texture);
border: 4px solid #1a1a1a;
border-top-color: #2a2a2a;
border-right-color: #2a2a2a;
}
.shop .wallet {
font-size: 20px;
font-weight: bold;
box-sizing: border-box;
width: 20em;
align-self: center;
text-align: center;
padding: .5em;
border-radius: 1.5em;
}
.shop main {
margin-top: 1rem;
padding-bottom: 1rem;
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 2rem 1rem;
border: 1rem solid #222;
border-image: var(--iron-texture);
border-image-repeat: round;
border-image-slice: 20;
box-shadow: inset -3px 3px 3px #111,
inset 3px -3px 5px #333;
}
.product {
display: flex;
flex-direction: column;
}
.pic-layout {
height: 100px;
min-width: 150px;
padding: 1rem;
display: flex;
align-items: center;
justify-content: center;
}
.pic-layout img {
max-width: 150px;
max-height: 100px;
background: #aaf;
outline: 5px solid #333;
}
.price {
width: 6em;
padding: .3em 1em;
border-radius: .5em;
align-self: center;
text-align: center;
}
#media screen and (max-width: 1000px) {
.shop main {
grid-template-columns: repeat(3, 1fr);
}
}
#media screen and (max-width: 700px) {
.shop main {
grid-template-columns: repeat(2, 1fr);
}
.shop .round {
position: static;
align-self: flex-end;
}
}
<section class="shop">
<header>
<h1>Welcome to the Shop</h1>
<p class="round">Round 1/10</p>
<p class="wallet iron-style">You have 1000 tokens</p>
</header>
<main>
<div class="product" id="product-1">
<div class="pic-layout">
<img src="https://picsum.photos/seed/prods1/150/100" />
</div>
<div class="price iron-style">5 Rubis</div>
</div>
<div class="product" id="product-2">
<div class="pic-layout">
<img src="https://picsum.photos/seed/prods2/150/100" />
</div>
<div class="price iron-style">25 Rubis</div>
</div>
<div class="product" id="product-3">
<div class="pic-layout">
<img src="https://picsum.photos/seed/prods3/150/100" />
</div>
<div class="price iron-style">15 Rubis</div>
</div>
<div class="product" id="product-4">
<div class="pic-layout">
<img src="https://picsum.photos/seed/prods4/150/100" />
</div>
<div class="price iron-style">42 Rubis</div>
</div>
<div class="product" id="product-5">
<div class="pic-layout">
<img src="https://picsum.photos/seed/prods5/150/100" />
</div>
<div class="price iron-style">120 Rubis</div>
</div>
<div class="product" id="product-6">
<div class="pic-layout">
<img src="https://picsum.photos/seed/prods6/150/100" />
</div>
<div class="price iron-style">33 Rubis</div>
</div>
<div class="product" id="product-7">
<div class="pic-layout">
<img src="https://picsum.photos/seed/prods7/150/100" />
</div>
<div class="price iron-style">6 Rubis</div>
</div>
<div class="product" id="product-8">
<div class="pic-layout">
<img src="https://picsum.photos/seed/prods8/150/100" />
</div>
<div class="price iron-style">44 Rubis</div>
</div>
<div class="product" id="product-9">
<div class="pic-layout">
<img src="https://picsum.photos/seed/prods9/150/100" />
</div>
<div class="price iron-style">99 Rubis</div>
</div>
<div class="product" id="product-10">
<div class="pic-layout">
<img src="https://picsum.photos/seed/prods10/150/100" />
</div>
<div class="price iron-style">1 Rubis</div>
</div>
<div class="product" id="product-11">
<div class="pic-layout">
<img src="https://picsum.photos/seed/prods11/150/100" />
</div>
<div class="price iron-style">23 Rubis</div>
</div>
<div class="product" id="product-12">
<div class="pic-layout">
<img src="https://picsum.photos/seed/prods12/150/100" />
</div>
<div class="price iron-style">16 Rubis</div>
</div>
</main>
</section>
This time I structured the shop with one wrapper div per product, but I could have avoided that using the same kind of grid as in my previous answer.
There are no vertical separators as CSS grid does not allow for inner borders (yet). If this is a requirement, the <main> element should be replaced with a <table>, which allows for all kinds of borders.
grid has the advantage of offering responsive layout using #media queries. That's why you can see all products on only 2 columns in the sample above, unless you enlarge it to full page.

My width is not changing forcing my divs to break up into two rows

Row
<div class="container" style="display:flex;
flex-direction: row;
justify-content: left;
align-items: left;
display: flex;
margin-bottom: 25px;
margin-left: -45px;
flex-wrap: wrap;
">
<p> </p>
<div class="box" style=" width: 210px; height: 340px; display:flex; border-style: dotted; border-width: 1px; border-color: rgb(230, 230, 230); flex-direction: column; max-width: 25rem; min-width: 18rem; align-items: left; justify-content: left; margin: 0px;
text-align: left;"><img font-family:lucida="" sans="" src="/images/contentimages/images/Baby - Copy 2.png" style="width: 208px; height: 208px; display: block; margin: auto; position: relative; top: 10px;" /><strong><span style="font-size:20px;"><span style="font-family:lucida sans unicode,lucida grande,sans-serif;"></span></span></strong><strong></strong><br />
<span style="font-size:18px;"> Baby<span style="font-size: 18px;"> </span><span style="font-weight: bolder;"> <a class="btn btn-info btn-sm edatalayer order-1" data-list="product-listing-page" data-position="1" data-purl="custom-business-forms" href="http://www.example.com/">View details <i class="far fa-chevron-right pl-1"></i></a> </span></span></div>
<div class="box" style=" width: 210px; height: 340px; display:flex; border-style: dotted; border-width: 1px; border-color: rgb(230, 230, 230); flex-direction: column; max-width: 25rem; min-width: 18rem; align-items: left; justify-content: left; margin: 0px;
text-align: left;"><img font-family:lucida="" sans="" src="/images/contentimages/images/Birthday - Copy 5.png" style="width: 208px; height: 208px; display: block; margin: auto; position: relative; top: 10px;" /><strong><span style="font-size:20px;"><span style="font-family:lucida sans unicode,lucida grande,sans-serif;"></span></span></strong><strong></strong><br />
<span style="font-size:18px;"> Birthday<span style="font-size: 18px;"> </span><span style="font-weight: bolder;"> <a class="btn btn-info btn-sm edatalayer order-1" data-list="product-listing-page" data-position="1" data-purl="custom-business-forms" href="http://www.example.com/">View details <i class="far fa-chevron-right pl-1"></i></a> </span></span></div>
<div class="box" style=" width: 210px; height: 340px; display:flex; border-style: dotted; border-width: 1px; border-color: rgb(230, 230, 230); flex-direction: column; max-width: 25rem; min-width: 18rem; align-items: left; justify-content: left; margin: 0px;
text-align: left;"><img font-family:lucida="" sans="" src="/images/contentimages/images/Business_Greetings - Copy 3.png" style="width: 208px; height: 208px; display: block; margin: auto; position: relative; top: 10px;" /><strong><span style="font-size:20px;"><span style="font-family:lucida sans unicode,lucida grande,sans-serif;"></span></span></strong><strong></strong><br />
<span style="font-size:18px;"> Business Greetings<span style="font-size: 18px;"> </span><span style="font-weight: bolder;"> <a class="btn btn-info btn-sm edatalayer order-1" data-list="product-listing-page" data-position="1" data-purl="custom-business-forms" href="http://www.example.com/">View details <i class="far fa-chevron-right pl-1"></i></a> </span></span></div>
<p> </p>
</div>
It seems like the 3rd box doesn't fit into the row?
I tried readjusting the width of the div, but it seems like that isn't the issue?
However when I remove flex-wrap option, the 3rd box goes back in the same row as the 2 other boxes?
This is because your boxes have a fixed width of 200px, from this style: width: 200px.
You can instead give them these attributes:
width: 33%;
max-width: 200px;
That will let the boxes have a max-width of 200px but resizing the width to have 30% of the container width if needed, not making them wrap into separate rows.
I highly suggest reorganizing the code using a style tag or a css file

How do I position these images to the right?

I have a website where users can rate something from 1 to 5 stars and the results are displayed on a bar graph. The code is as follows:
.ratings-container {
/*background-color: orange;*/
font-family: tahoma;
padding-top: 50px;
padding-bottom: 50px;
padding-left: 50px;
}
.ratings-container h3 {
padding-bottom: 20px;
}
.graph-container {
/* background-color: blue;*/
width: 66%;
}
.graph {
border-left: 2px solid black;
border-bottom: 2px solid black;
display: flex;
justify-content: space-around;
align-items: flex-end;
height: 300px;
width: 100%;
/*background-color: red;*/
}
.graph div {
width: 12%;
height: 1px;
background-color: black;
}
.counters {
display: flex;
justify-content: space-around;
align-items: center;
width: 100%;
}
.label-container {
width: 98%;
/*background-color: green;*/
}
#fivestar {
float: left;
/*display: inline;*/
}
#onestar {
float: right;
/*display: inline;*/
}
.star-container {
width: 25%;
/*background-color: blue;*/
margin-top: 100px;
font-size: 0;
}
.star {
width: 50px;
height: auto;
cursor: pointer;
transition: 0.3s;
}
#feedback-thanks {
display: none;
transition: 0.5s;
padding-top: 20px;
}
<div class="ratings-container">
<h3 style="font-family: Georgia" id="ratings-heading">RATE YOUR STAY</h3>
<div class="graph-container">
<div class="graph">
<div id="bar5"></div>
<div id="bar4"></div>
<div id="bar3"></div>
<div id="bar2"></div>
<div id="bar1"></div>
</div>
<div class="counters">
<h3 id="c5">0</h3>
<h3 id="c4">0</h3>
<h3 id="c3">0</h3>
<h3 id="c2">0</h3>
<h3 id="c1">0</h3>
</div>
<div class="label-container">
<h2 id="fivestar">5 star</h2>
<h2 id="onestar">1 star</h2>
</div>
</div>
<div class="star-container">
<img class="star" id="star1" src="./star.jpg">
<img class="star" id="star2" src="./star.jpg">
<img class="star" id="star3" src="./star.jpg">
<img class="star" id="star4" src="./star.jpg">
<img class="star" id="star5" src="./star.jpg">
</div>
<h3 id="feedback-thanks">Thanks for your feedback!</h3>
</div>
However I'm having trouble positioning the images at the bottom (which are stars). I would like them to be on the right hand side of the bar graph, not below it. I've tried taking them out of the 'ratings-container' div and making them inline elements but to no avail.
You can easily achieve that with a flexbox. I have documented the changes in the CSS code.
Vertical alignment of the flexbox items can be changed.
.ratings-container {
/*background-color: orange;*/
font-family: tahoma;
padding-top: 50px 0 50px 50px;
display: flex; /* Added */
flex-wrap: wrap; /* Added */
}
.ratings-container h3 {
padding-bottom: 20px;
width: 100%;
}
.graph-container {
/* background-color: blue;*/
width: 66%;
}
.graph {
border-left: 2px solid black;
border-bottom: 2px solid black;
display: flex;
justify-content: space-around;
align-items: flex-end;
height: 300px;
width: 100%;
/*background-color: red;*/
}
.graph div {
width: 12%;
height: 1px;
background-color: black;
}
.counters {
display: flex;
justify-content: space-around;
align-items: center;
width: 100%;
}
.label-container {
width: 98%;
/*background-color: green;*/
}
#fivestar {
float: left;
/*display: inline;*/
}
#onestar {
float: right;
/*display: inline;*/
}
.star-container {
width: 25%;
/*background-color: blue;*/
margin-top: 100px;
font-size: 0;
}
.star {
width: 50px;
height: auto;
cursor: pointer;
transition: 0.3s;
}
#feedback-thanks {
display: none;
transition: 0.5s;
padding-top: 20px;
}
<div class="ratings-container">
<h3 style="font-family: Georgia" id="ratings-heading">RATE YOUR STAY</h3>
<div class="graph-container">
<div class="graph">
<div id="bar5"></div>
<div id="bar4"></div>
<div id="bar3"></div>
<div id="bar2"></div>
<div id="bar1"></div>
</div>
<div class="counters">
<h3 id="c5">0</h3>
<h3 id="c4">0</h3>
<h3 id="c3">0</h3>
<h3 id="c2">0</h3>
<h3 id="c1">0</h3>
</div>
<div class="label-container">
<h2 id="fivestar">5 star</h2>
<h2 id="onestar">1 star</h2>
</div>
</div>
<div class="star-container">
<img class="star" id="star1" src="./star.jpg">
<img class="star" id="star2" src="./star.jpg">
<img class="star" id="star3" src="./star.jpg">
<img class="star" id="star4" src="./star.jpg">
<img class="star" id="star5" src="./star.jpg">
</div>
<h3 id="feedback-thanks">Thanks for your feedback!</h3>
</div>
try making the div containing stars Inline with previous div.