Why do my span box changes shape on mobile view - html

You can see in the picture below, it displays normally on desktop, but changes on a mobile view.
I created this box with a span and added some objects in it, but I noticed, and don't know why it will show properly on PC and changes shape on Mobile even after setting the overflow-x to scroll. Someone help me with this please.
See the image here.
This is the html code:
```
<div>
<div class="suggestion_container">
<span class="suggestion-box">
<img class="sug-img" src="images/legion.png">
<h1 class="sug-name">Legion Network</h1>
<h2 class="sug-price">800,000</h2>
</span>
<span class="suggestion-box">
<img class="sug-img" src="images/holo.png">
<h1 class="sug-name">Holo</h1>
<h2 class="sug-price">800,000</h2>
</span>
<span class="suggestion-box">
<img class="sug-img" src="images/safepal.png">
<h1 class="sug-name">SafePal</h1>
<h2 class="sug-price">1,500,000</h2>
</span>
<span class="suggestion-box">
<img class="sug-img" src="images/kava.png">
<h1 class="sug-name">Kava</h1>
<h2 class="sug-price">1,500,000</h2>
</span>
<span class="suggestion-box">
<img class="sug-img" src="images/compound.png">
<h1 class="sug-name">Compound</h1>
<h2 class="sug-price">1,500,000</h2>
</span>
</div>
</div>```
This is the css style:
.sug-img {
padding: 6px 0px 0px 6px;
width: 40px;
height: 40px;
}
.sug-name {
font-size: 18px;
margin-top: 50px;
position: absolute;
left: 6px;
}
.sug-price {
font-size: 18px;
margin-top: 75px;
position: absolute;
left: 6px;
}
.suggestion-box {
position: relative;
height: 100px;
width: 152px;
background-color: white;
margin-right: 12px;
border-radius: 10px;
display: flex;
border: 1px solid;
}
.suggestion_container {
display: flex;
padding-top: 70px;
margin: -70px 20px 0px 20px;
overflow-x: scroll;
white-space: nowrap;
}

The width CSS attribute is overridden for items inside a display:flex container.
You can either:
add a min-width: 150px to .suggestion-box, this will ensure that the item's width can get shrunk, but never below 150px
add flex-shrink: 0 and flex-basis: 150px to .suggestion-box which will render the items at 150px to begin width, but will never shrink below that value, only grow.
Both approaches will end up with the same result.
.suggestion-box {
position: relative;
height: 100px;
flex: 1 0 150px;
background-color: white;
margin-right: 12px;
border-radius: 10px;
display: flex;
border: 1px solid;
}

Related

Div goes off screen on Firefox when lower width viewport / Not on chrome

I have a div element on my page that is relatively positioned to a parent div
Element in question's CSS (it have both classes) :
.message {
width: 300px;
padding: 0 16px 0 16px;
background-color: #ffffff;
position: relative;
border-radius: 8px;
color: #4A4A4A;
text-transform: initial;
text-align: left;
line-height: normal;
font-weight: 400;
pointer-events: auto;
}
.message-three {
left: -105px;
top: -250px;
margin-right: 20px;
/* margin-right: auto; */
}
It's parent's (both classes also) :
.spot {
z-index: 4;
width: 100px;
height: 100px;
box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
border-radius: 75px;
margin: 0 auto;
}
.spot-three {
top: -1px;
left: 9px;
display: none;
position: absolute;
z-index: 4;
}
When I redimension my viewport (width) with navigator's dev tool :
on Chrome, the right border of the screen "pushes" my element so it keeps the 20px margin-right (and below a certain viewport, all the elements of the page shrink)
On Firefox elements keep the same size regardless of the viewport but my element is going off the screen of the right
I want to prevent my element from going off-screen on Firefox but I don't know-how
EDIT:
Html
<div id="data-bar" class="row data-project">
<div class="col-sm-2">
...
</div>
<div class="col-sm-2">
...
</div>
<div class="col-sm-2" style="position: relative; z-index:4;">
<div class="spot spot-three">
<div class="message message-three">
<h2 class="message-title">{{'info.thirdMessage.title'|trans}}</h2>
<p class="message-text">{{'info.thirdMessage.message'|trans|nl2br}}</p>
<div class="message-bottom-line">
<div>
<i class="far fa-circle dot-empty"></i>
<i class="far fa-circle dot-empty"></i>
<i class="fas fa-circle dot-full"></i>
</div>
<button class="menu-item primary-button" onclick="hideMessage()">{{'info.close.btn'|trans}}</button>
</div>
</div>
</div>
</div>
</div>
data-bar CSS :
#data-bar {
position: fixed;
z-index: 2;
width: calc(100% - 40px);
bottom: 20px;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
background-color: #505050;
margin-left: 20px;
justify-content: stretch;
border : solid;
border-top-width: 1px;
border-left-width: 1px;
border-right-width: 1px;
border-bottom-width: 0px;
border-color: #3E3E3E;
color: white;
}
col-sm-2 CSS :
.col-sm-2 {
padding: 20px;
max-width: 20%;
flex: auto;
}

How to remove background gap of text messages CSS

I'm building a React Chat app. My background of messages works fine with a short text. The background responsively changes according to text-content.
With longer text, when I scale the browser, there are certain points where the background appears larger than the fit-content. Below are the pictures of the same message.
No Gap
With Gap
Here is my React code:
<div className={`chatMessage ${message.sender._id === state._id && "myMessage"}`}>
<div className="messageHeader">
<span className="chatName"> {message.sender.name} </span>
<span className="timeStamp"> {message.timestamp.substring(0, 10)} </span>
</div>
<div className="messageContent">
<span>{message.message}</span>
<small className="timeStamp"> {message.timestamp.substring(12, 20)} </small>
</div>
</div>
Here is my CSS:
.chatMessage {
display: flex;
height: auto;
position: relative;
font-size: 16px;
padding: 2px 10px 0px 10px;
max-width: 350px;
margin-bottom: 10px;
}
.myMessage > .messageContent {
background-color: #dcf8c6 !important;
}
.chatMessage > .messageContent {
background-color: rgb(221, 221, 221);
}
.messageContent {
position: relative;
bottom: 25px;
padding: 2px 10px 0px 10px;
border-radius: 10px;
right: -5px;
}
I believe the max-width property is causing the problem. But I can't figure out how to work around it.

Hover Overlap Issue With a List of boxes

I am dynamically creating a bunch of cards. These cards will have an image and some text. When hovering over the image within the card, a bigger image is displayed in the middle of the page.
There are a total of 16 cards on the page. There are four rows with 4 cards in each row. The issue is: when hovering over the 1st card, all the text or images of the next 15 cards overlap the large image that appears when hovering over the small image on the 1st card. When hovering over let’s say the 3rd card, the image is only overlapped by the text/images of cards that appear after that 3rd card. If I hover over the image of the last card on the page, this issue does not occur. Therefore, all the div’s after the card that is being hovered over cause this issue of overlapping.
Things I have tried: z-index which does not work because each card is being generated dynamically. I have also tried to change the position: static or inherit to see if that would help.
Not sure what the problem is and how to fix it?
<div class="biz-card center-block">
<div class="biz-container">
<div class="biz-row">
<div class="col-sm-6">
<div class="biz-photo">
<div class="rounded biz-wrapper"></div>
</div>
</div>
<div class="col-sm-6" style="display: flex;">
<div class="biz-content">
<h6 href="#home">John Doe</h6>
<p class="left-align">Name</p>
</div>
</div>
</div>
</div>
</div>
.biz-card {
min-width: 350px;
max-width: 350px;
min-height: 250px;
max-height: 250px;
border: thin;
border-color: lightgrey;
box-shadow: 3px 6px 6px -2px rgba(0,0,0,0.58);
z-index: 1;
}
.biz-container {
padding-right: 0;
padding-left: 0;
margin-right: auto;
margin-left: auto;
height: 250px;
}
.biz-row {
display: flex;
align-items: center;
margin-left: auto;
margin-right: auto;
margin-bottom: 20px;
height: 250px;
}
.biz-photo {
position: relative;
display: block;
width: 145px;
height: 64px;
}
.biz-photodetailed {
display: none;
background: #424242;
opacity: 1;
filter: alpha(opacity=100); /* For IE8 and earlier */
z-index: 1000;
bottom: 0;
height: 848px;
width: 605px;
/*margin: auto;*/
position: fixed;
top: 50%;
left: 50%;
margin-top: -424px; /* Half the height */
margin-left: -302px; /* Half the width */
border: 2px solid #fff;
box-shadow: 10px 10px 5px #ccc;
-moz-box-shadow: 10px 10px 5px #ccc;
-webkit-box-shadow: 10px 10px 5px #ccc;
/*-khtml-box-shadow: 10px 10px 5px #ccc;*/
}
.biz-photo:hover .biz-photodetailed {
display:block;
}
Would anyone be able to help out?

Settings a border around several divs

I am trying to make a product summary box for the following page:
I was playing around to set the border on the following divs:
<div style="border:1px solid black;" class="inner">
<div style="padding-bottom: 14px;border:1px solid black;" class="title">
The result looks like the following:
I would like to let it look like that:
Any suggestions how to set the divs properly? Or would it be better to design a backgroud image to fit the box?
I appreciate your replies!
You could use a tableinstead of DIVs whose cell borders you make visible.
Or use display: table , display: table-row and display: table-cell for the DIVs, again defining a border for the cell elements.
This is a 5-minute CSS solution:
* {
box-sizing: border-box;
font-family: sans-serif;
}
.product {
border: 2px solid #999;
border-radius: 2px;
width: 20em;
}
.product--header,
.product--image,
.product--rating {
width: 100%;
border-bottom: 2px solid #999;
}
.product--header h2, .product--header h3 {
text-align: center;
padding: 0.25em 0 0.5em;
margin: 0;
}
.product--image img {
width: 100%;
padding: 0.25em;
z-index: 1;
}
.product--image {
position: relative;
}
.product--pricetag {
position: absolute;
z-index: 2;
left: 0;
top: 1em;
color: white;
background: rgba(0, 0, 0, 0.75);
text-align: center;
width: 40%;
padding: 0.5em;
}
.product--rating p {
text-align: center;
}
.product--links {
width: 100%;
margin: 0.5em;
}
.product--links a.btn {
display: block;
color: white;
background: blue;
text-align: center;
width: 90%;
margin-left: 2.5%;
padding: 0.5em;
margin-bottom: 0.25em;
}
<div class="product">
<div class="product--header">
<h2>Test Product</h2>
<h3>Price Class: $$ | P3 | 14</h3>
</div>
<div class="product--image">
<img src="http://placekitten.com/200/200" alt="cat">
<p class="product--pricetag">
999 $
</p>
</div>
<div class="product--rating">
<p>Rating: 4/5</p>
</div>
<p class="product--links">
<a class="btn">Buy on Amazon</a>
<a class="btn">Other Sizes</a>
</p>
</div>
I wouldn't recommend a background frame image, because it's a pain to work with and loading it is a waste of bandwidth.
Put four borders on the container, then just add border-bottom in each child, except on the last.
.container-bordered {
border: 2px solid red;
}
.container-bordered > div:not(:last-of-type) {
border-bottom: 2px solid red;
}
https://jsfiddle.net/cqjxuype/

Stacking images using CSS and HTML

In my code I have 5 div boxes lined up in a 900px container div. I'm have pictures inside the divs and text at the bottom. Both the pictures and text are in their own a href tags linking to the same place (because I wanted the text to :hover and this was the only way to do it).
So I need a SALE icon ONTOP of the pictures and on the edge (0px) of the border. The red sale icon is 100x100px (and at the very bottom, alone, in my sample HTML code). Everytime I use position: relative or position: absolute it pushed the picture and text in the div DOWN. How do I get the one on top of the other?? What am I doing wrong here? Here is the website right now: http://user2cis133.achins.com/final/
Here is some JSFiddle:
http://jsfiddle.net/gzbvejry/
Also I've read a shitton of articles on this and even copied and pasted their code and changed it for this and it still doesn't work.
#second {
background-color: #fff;
width: 210px;
height: 390px;
float: right;
border: 1px #000 solid;
border-radius: 10px 10px 10px 10px;
margin-left: 4px;
margin-top: 10px;
text-align: center;
}
a.hvr:link {
color: #696969;
}
a.hvr:hover {
color: #6495ED;
}
.brd {
position: abosolute;
margin: 5px;
}
#sale {
display: block;
left: 70px;
top: 0px;
}
<div id="second">
<a href="#">
<img class="brd" src="images/blue prom1.jpg" width="200px" heigth="380px" />
</a>
<a class="hvr" href="#">
Empire Waist Blue Prom Dress <br>
$150
</a>
</div>
<img src="images/sale.png" width="100px" height="100px"/>
give position:relative in #second{}.Also check the spelling of absolute in #sale, its wrong in the link
#second {
background-color: #fff;
width: 210px;
height: 390px;
float: right;
border: 1px #000 solid;
border-radius: 10px 10px 10px 10px;
margin-left: 4px;
margin-top: 10px;
text-align: center;
position:relative;
}
#sale {
position: absolute;
right: -49px;
top: -6px;
}
<div id="second">
<div class="sticker sticker-new"></div>
<a href="#">
<img class="brd" src="http://user2cis133.achins.com/final/images/aquaprom.jpg" width="200px" heigth="380px" />
</a>
<a class="hvr" href="#">
Empire Waist Blue Prom Dress <br>
$150
</a>
#second {
background-color: #fff;
width: 210px;
height: 390px;
border: 1px #000 solid;
border-radius: 10px 10px 10px 10px;
margin-left: 4px;
margin-top: 10px;
text-align: center;
}
a.hvr:link {
color: #696969;
}
a.hvr:hover {
color: #6495ED;
}
.brd {
margin: 5px;
}
#sale {
position: relative;
display: block;
left: 70px;
top: 0px;
}
.sticker-new {
background: url(http://user2cis133.achins.com/final/images/sale.png) no-repeat;
left: auto;
right: 0;
}
.sticker {
position: absolute;
top: 0;
left: 68px;
width:171px;
height:171px;
}