aligning of 5 boxes using flex is giving spacing issue - html

I've been working with grid layout, it's working fine in all browsers except in IE
Issue with grid layout in IE11
Now i've been trying the same structure with flex 3 cols * 2 rows but somehow it is not getting as expected because of spaces for the last 2 boxes.
Hope you can help me out with your suggestions either in the grid issue Issue with grid layout in IE11
or with the flex
.grid_container{
margin: 10px auto;
max-width: 1100px;
width: 100%;
height: auto;
display: flex;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
flex-direction: row;
justify-content: space-around;
flex-flow: wrap;
}
.box-item {
width: 30%;
height: auto;
position: relative;
}
.box-item img {
max-width: 100%;
max-height: 100%;
vertical-align: bottom;
min-height: 200px;
}
.box-text {
position: absolute;
bottom: 12px;
left: 0;
right: 0;
width: 100%;
text-align: center;
font-size: 1.3rem;
font-weight: 400;
color: white;
}
#media only screen and (max-width: 1200px) {
.box-item {
width: 45%;
}
}
#media only screen and (max-width: 1200px) {
.box-item {
width: 90%;
}
}
/* Smartphones (portrait) ----------- */
#media only screen and (max-width: 320px) {
}
/* Smartphones (portrait and landscape) ----------- */
#media only screen and (min-width: 320px) and (max-width: 479px) {
}
#media only screen and (max-width: 767px) {
}
/* Tablets potrait----------- */
#media only screen and (min-width: 480px) and (max-width: 767px) {
}
/* Tablets (portrait and landscape) ----------- */
#media only screen and (min-width: 768px) and (max-width: 1024px) {
}
#media only screen and (min-width: 768px) and (max-width: 991px) {
}
/*--------#media only screen and (min-width: 992px){ } ----------- */
/* Desktops and laptops ----------- */
#media only screen and (min-width: 1224px) {
}
/* Desktops and laptops ----------- */
#media only screen and (min-width: 1400px) {
}
<div class="grid_container">
<div class="box-item">
<img src="https://i.picsum.photos/id/255/200/200.jpg?hmac=IYQV36UT5-F1dbK_CQXF7PDfLfwcnwKijqeBCo3yMlc" />
<div class="box-text">
dummy text
</div>
</div>
<div class="box-item">
<img src="https://i.picsum.photos/id/255/200/200.jpg?hmac=IYQV36UT5-F1dbK_CQXF7PDfLfwcnwKijqeBCo3yMlc" />
<div class="box-text">
dummy text
</div>
</div>
<div class="box-item">
<img src="https://i.picsum.photos/id/255/200/200.jpg?hmac=IYQV36UT5-F1dbK_CQXF7PDfLfwcnwKijqeBCo3yMlc" />
<div class="box-text">
dummy text
</div>
</div>
<div class="box-item">
<img src="https://i.picsum.photos/id/255/200/200.jpg?hmac=IYQV36UT5-F1dbK_CQXF7PDfLfwcnwKijqeBCo3yMlc" />
<div class="box-text">
dummy text
</div>
</div>
<div class="box-item">
<img src="https://i.picsum.photos/id/255/200/200.jpg?hmac=IYQV36UT5-F1dbK_CQXF7PDfLfwcnwKijqeBCo3yMlc" />
<div class="box-text">
dummy text
</div>
</div>
</div>

You may add this to the css which mimics flex display fo IE:
_:-ms-lang(x),
.ie10up {
/* IE10+ CSS styles go here */
.grid_container {
margin: 10px auto;
max-width: 1100px;
width: 100%;
height: auto;
display: inline-table;
}
.box-item {
position: relative;
display: inline;
text-align: center;
}
}

Add the following code to your exiting one. Please update the width to take 1/3 of total width. Also add max-width so that it doesn't exceed that width.
.box-item {
width: 33%;
max-width: 33%;
}

Related

How can I place a row of 4 square images that reduce into 2 rows of 2 square images using flexbox, with 40px between everything including the sides

HTML
<div class="container">
<div class="photos" id="box">
<img src="image1.jpg">
<img src="image2.jpg">
<img src="image3.jpg">
<img src="image4.jpg">
</div>
</div>
CSS
.container {
max-width: 1280px;
margin: 0 auto;
}
.photos {
display: flex;
background-color: #000;
flex-direction: row;
flex-wrap: wrap;
justify-content: flex-start;
align-content: stretch;
padding: 0;
max-width: 1280px;
}
.photos img {
display: block;
float: left;
flex: 0 0 auto;
background-color: #fff;
width: calc(25%-120px);
/*
box-sizing: border-box;
border-right: 40px solid #FFFFFF;
*/
}
#media screen and (min-width: 1024px) {
.photos img {
width: calc(100%/4);
height: calc(100%/4);
}
}
#media screen and (min-width: 769px) and (max-width: 1024px) {
.photos img {
width: calc(100%/4);
height: calc(100%/4);
}
}
#media screen and (min-width: 481px) and (max-width: 768px) {
.photos img {
width: calc(100%/2);
height: calc(100%/2);
}
}
#media screen and (min-width: 321px) and (max-width: 480px) {
.photos img {
width: calc(100%/2);
height: calc(100%/2);
}
}
#media screen and (max-width: 320px) {
.photos img {
width: 100%;
height: 100%;
}
}
How can I place a row of 4 square images that reduce into 2 rows of 2 square images using flexbox, with 40px between everything including the sides
Unable to get a 40px gap between images, messes with calc grid, not sure on how to easily create a grid with 40px gap between everything (including by the edges of the page)

Bootstrap - set min and max width of div - not number of columns

I need to make number of columns set according to width of screen not to chose if there is a 3, 4, 5 or 6
this is your solution, you need the media query's for CSS
https://jsfiddle.net/Alan_van_Buuren/4w9wy73y/
.column {
width: 50px;
font-size: 20px;
float: left;
}
#media screen and (min-width: 480px) {
.column {
width: 100px;
}
}
#media screen and (max-width: 800px) and (min-width: 520px) {
.column {
width: 100px;
background-color: yellow;
}
}
#media screen and (max-width: 519px) and (min-width: 100px) {
.column {
width: 150px;
background-color: red;
}
}
<div class="column">One</div>
<div class="column">Two</div>
<div class="column">Three</div>
<div class="column">Four</div>
<div class="column">Five</div>
<div class="column">Six</div>
<div class="column">Seven</div>
<div class="column">Eight</div>
<div class="column">Nine</div>
<div class="column">Ten</div>
<div class="column">Eleven</div>
<div class="column">Tweelve</div>

css media not working on browser size but working on zoom or Responsive Design View

I have an odd problem. my media queries not working when I resize the window size of my browser but it's working on zoom. It works on Responsive Design View of firefox too.
here is my ccs media queries:
https://jsfiddle.net/5n9kv2g5/1/
html:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv=X-UA-Compatible content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="author" content="">
<link rel="stylesheet" href="css/style.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
</head>
<body>
<div class="row">
<div class="col-1">
</div>
<div class="col-2">
</div>
</div>
</body>
</html>
css:
body{
margin:auto;
}
a{
text-decoration: none;
}
.box{
position:absolute;
top:7rem;
height: 27rem;
}
.col-1{
width: 60%;
float:left;
position: relative;
background: #262626;
height: 40rem;
min-height: 100vh;
}
.col-2{
width: 40%;
float: left;
background: #303030;
position: relative;
height: 40rem;
min-height: 100vh;
}
/* Smartphones (portrait and landscape) ----------- */
#media only screen and (min-device-width : 320px) and (max-device-width : 479px) {
/* Styles */
.col-1{
display: none;
}
.col-2{
background:#303030 url("../images/logo.png") top center no-repeat;
-webkit-background-size:50%;
background-size:30%;
width: 100%;
height: 32rem;
}
}
#media only screen and (min-device-width : 480px) and (max-device-width : 639px) {
/* Styles */
.col-1{
display: none;
}
.col-2{
background:#303030 url("../images/logo.png") top center no-repeat;
-webkit-background-size:50%;
background-size:30%;
width: 100%;
height: 34rem;
}
}
#media only screen and (min-device-width : 640px) and (max-device-width : 767px) {
/* Styles */
.col-1{
display: none;
}
.col-2{
background:#303030 url("../images/logo.png") top center no-repeat;
-webkit-background-size:50%;
background-size:30%;
width: 100%;
height: 35rem;
}
}
#media only screen and (min-device-width : 768px) and (max-device-width : 1023px) {
.col-1{
width: 100%;
height: 33rem;
min-height: 0;
}
.box{
top:8rem;
height: 25rem;
}
.col-2{
width: 100%;
height: 30rem;
}
}
EDIT / NEW ANSWER:
Use this
#media only screen and (min-width : 320px) and (max-width : 479px)
instead of this
#media only screen and (min-device-width : 320px) and (max-device-width : 479px)
(And the same in all other sections - min-width instead of min-device-width etc.)
https://jsfiddle.net/1wbjp0pp/
If that isnt working i suspect you havnt added the viewport meta tag
<meta name="viewport" content="width=device-width, initial-scale=1">
Try this code. Hope, It will work for you.
Html
<body class="preload" ng-app="loginApp" ng-cloak>
<div class="row">
<div class="col-1">
</div>
<div class="col-2">
</div>
</div>
</body>
CSS
body{
margin:auto;
}
a{
text-decoration: none;
}
.box{
position:absolute;
top:7rem;
height: 27rem;
}
.col-1{
width: 60%;
float:left;
position: relative;
background: #262626;
height: 40rem;
min-height: 100vh;
}
.col-2{
width: 40%;
float: left;
background: #303030;
position: relative;
height: 40rem;
min-height: 100vh;
}
/* Smartphones (portrait and landscape) ----------- */
#media only screen and (min-width : 320px) and (max-width : 479px) {
/* Styles */
.col-1{
display: none;
}
.col-2{
background:#303030 url("../images/logo.png") top center no-repeat;
-webkit-background-size:50%;
background-size:30%;
width: 100%;
height: 32rem;
}
}
#media only screen and (min-width : 480px) and (max-width : 639px) {
/* Styles */
.col-1{
display: none;
}
.col-2{
background:#303030 url("../images/logo.png") top center no-repeat;
-webkit-background-size:50%;
background-size:30%;
width: 100%;
height: 34rem;
}
}
#media only screen and (min-width : 640px) and (max-width : 767px) {
/* Styles */
.col-1{
display: none;
}
.col-2{
background:#303030 url("../images/logo.png") top center no-repeat;
-webkit-background-size:50%;
background-size:30%;
width: 100%;
height: 35rem;
}
}
#media only screen and (min-width : 768px) and (max-width : 1023px) {
.col-1{
width: 100%;
height: 33rem;
min-height: 0;
}
.box{
top:8rem;
height: 25rem;
}
.col-2{
width: 100%;
height: 30rem;
}
}

Position the divs in the center of the container in every window width

I came with a design feature I want to add to my website. I have a container that hold informations about user.The container holds dynamically created divs,this means that in every user account the number of divs changes. My main goal is to add responsive style so my container hold exactly the same number of divs in every device width, positioned in the center.
Problem
The problem is in the horizontal align of the divs. Look in the next images:
If we have a width of 768px then the interface looks as expected
If we resize the window to eg. 850px width then the results are the following:
You see that the divs aren't positioined in the center of the screen so that a blank space is created. Moreover it should appear one more div as the width of the page expanding if we have the appropriate space to hold one more div in the line. Now think that there could be many rows not just or two. And every column should position the elements in the same place.
I know that my explanation isn't the greatest so if you have any questions please ask.
How can I fix the css rules to cender my divs in the different window widths?
My css file is the following:
/* CONTAINER */
.seas {
margin-right: auto;
margin-left: auto;
}
/* THE INNER BOXES DIVS */
.sea {
min-width: 250px;
min-height: 300px;
display: inline-block;
margin-top: 20px;
margin-right: 10px;
}
#media screen and (max-width: 980px) {
.sea {
margin-left: 20px;
}
}
#media screen and (max-width: 800px) {
.sea {
margin-left: 50px;
}
}
#media screen and (max-width: 360px) {
.sea {
margin-left: 20px;
}
}
#media screen and (max-width: 320px) {
.sea {
margin-left: 5px;
}
}
The html file
<div class="seas" id="seas">
<div class="sea homeWindow"> </div>
<div class="sea homeWindow"> </div>
<div class="sea homeWindow"> </div>
<div>
Update - (Not) Possible Duplicate -
To answer for the duplicate tag, this question is not duplicate. I understand if you think that it is, cause my question is referring to a more advance web design style than the majority of questions here.I had hard time myself to describe what I wanted. Anyway I found the solution on my own , and thanks to the answer were posted.
So, based on our conversation, I'm adding one fluid design solution, you can look here
http://jsbin.com/rohoqolapa/1/edit?output
All CSS you need is following
/* CONTAINER */
.seas {
margin-right: auto;
margin-left: auto;
}
/* THE INNER BOXES DIVS */
.sea {
min-width: 250px;
min-height: 300px;
display: inline-block;
margin-top: 20px;
margin-right: 10px;
background: red;
box-sizing: border-box;
width: 33.33%;
}
EDIT: - Since changing width is not required and content needs to be center aligned, basically this might be the solution
http://jsbin.com/hapeqerosi/1/edit?output
All you have to do is to change parents css -
.seas {
text-align: center;
}
Your parent div .seas is actually block level element, so you should rather align all it's child centrally.
You should add text-align:center to parent .seas so the inner .sea with display:inline-block; to cover the white space .
.seas {
margin-right: auto;
margin-left: auto;
text-align:center;
}
/* THE INNER BOXES DIVS */
.sea {
min-width: 250px;
min-height: 300px;
display: inline-block;
margin-top: 20px;
margin-right: 10px;
background-color:Red;
vertical-align:top
}
#media screen and (max-width: 980px) {
.sea {
margin-left: 20px;
}
}
#media screen and (max-width: 800px) {
.sea {
margin-left: 50px;
}
}
#media screen and (max-width: 360px) {
.sea {
margin-left: 20px;
}
}
#media screen and (max-width: 320px) {
.sea {
margin-left: 5px;
}
}
<div class="seas" id="seas">
<div class="sea homeWindow"> </div>
<div class="sea homeWindow"> </div>
<div class="sea homeWindow"> </div>
<div>
Check this JSFiddle
I think it's what you want
HTML:
<div class="box">
<div class="wrapper">
<div>
<img src="http://placehold.it/200x200" />
</div>
<div>
<img src="http://placehold.it/200x200" />
</div>
<div>
<img src="http://placehold.it/200x200" />
</div>
<div>
<img src="http://placehold.it/200x200" />
</div>
</div>
</div>
CSS:
.box {
width: 100%;
}
.wrapper {
display: table;
margin: 0 auto;
}
.wrapper>div {
display: inline-block;
border: none;
}
#media (max-width: 400px) {
.wrapper {
width: 200px;
}
}
#media (min-width: 401px) {
.wrapper {
width: 400px;
}
}
#media (min-width: 601px) {
.wrapper {
width: 600px;
}
}
#media (min-width: 801px) {
.wrapper {
width: 800px;
}
}
The solution is here:
#media only screen and (max-device-width: 980px) {
.seas {
max-width: 90%;
}
.sea {
margin-right: 20px;
}
}
#media only screen and (max-device-width: 970px) {
.seas {
max-width: 100%;
}
.sea {
margin-right: 20px;
}
}
#media only screen and (max-device-width: 800px) {
.seas {
max-width: 80%;
}
.sea {
margin-right: 20px;
}
}
#media only screen and (max-device-width: 770px) {
.seas {
max-width: 80%;
}
}
#media only screen and (max-device-width: 360px) {
.seas {
max-width: 85%;
}
}
#media only screen and (max-device-width: 320px) {
.seas {
max-width: 100%;
}
}

#Media for image design

I am working on a site and I have two images that need to be inline when device width is more than 425px (min-width: 425px) but for some reason it does not seem to be working how it should be and my css with the #media but it doesn't work for some reason although it is fairly basic
CODE
.info-img {
width: 49.75%;
}
.info-images {
display: inline-block;
text-align: center;
}
#media screen and only (max-width: 425px) {
.info-img {
width: 100%;
padding-bottom: 1px;
}
.info-images {
display: block;
text-align: center;
}
}
<div class="info-images">
<img src="https://dl.dropboxusercontent.com/s/dd5exdwwpa13yxnthg/unspecified-4.jpeg?dl=0" class="info-img">
<img src="https://dl.dropboxusercontent.com/s/fo3bt6ruhx4qppztho/unspecified-6.jpeg?dl=0" class="info-img">
</div>
</div>
<style type="text/css">
#import url('https://dl.dropboxusercontent.com/s/ikcsorhvohzdipo/information.css?dl=0');
</style>
The problem is because you are giving inline-block to parent instead of img, plus you are writing your media wrongly (its not #media screen and only, but #media only screen and).
Snippet
.info-images {
font-size: 0;
/* fix inline-block gap */
}
.info-img {
width: 50%;
display: inline-block;
vertical-align:top; /* may be necessary */
box-sizing: border-box;
padding: 0 1%
}
#media only screen and (max-width: 425px) {
.info-img {
width: 100%;
padding-bottom: 1px;
}
.info-images {
display: block;
text-align: center;
}
}
<div class="info-images">
<img src="//lorempixel.com/1600/900" class="info-img">
<img src="//lorempixel.com/1600/900" class="info-img">
</div>