Reputation: 11
I'm so sorry about the dumb question, but i've been stuck on the same problem for 4+ hours with creating three columns side by side in the center of the page. I've tried margin auto, using position absolute but I cant get them center.
It literally making me want to pull out my hair and i've tried formatting it in 50 different ways.
#IARA {
width: px margin:0 auto;
}
body {
margin: 0 padding:0px;
}
#IARAlogo {
margin-top: 10px;
margin-right: 10px;
pointer-events: none;
float: right;
}
#checkout {
margin-top: 10px;
margin-left: 10px;
float: left;
pointer-events: none;
}
.CLEARTOPBAR {
clear: both;
display: block;
margin: auto;
}
#leftpanel {
background-color: orange;
width: 20%;
height: 50%;
padding: 25px;
}
#Middlepanel {
background-color: blue;
width: 35%;
height: 50%;
padding: 25px;
}
#Rightpanel {
background-color: pink;
width: 20%;
height: 50%;
padding: 25px;
}
<div id="IARA">
<img id="IARAlogo" src="iaraplaceholder.png" style="width:50px;height:40px;" draggable="false" unselectable: "on">
<img id="checkout" src="IARAcheckout.jpg" style="width:70px;height:60px;" draggable="false" unselectable: "on">
</div>
<div class="CLEARTOPBAR">
<div id="Leftpanel">
</div>
<div id="Middlepanel">
</div>
<div id="Rightpanel">
</div>
</div>
Upvotes: 0
Views: 275
Reputation: 201
Here are snippets I frequently use. These snippets are designed to be used as DIV class declarations in a STYLE. Simply place your text inside a div. i.e <div class="3col">Text to be 3 columns</div>
. I like this because it allows me to have multiple column styles within the page.
<style>
.2col {
-webkit-column-count: 2; /* Chrome, Safari, Opera */
-moz-column-count: 2; /* Firefox */
column-count: 2;
-webkit-column-gap: 30px; /* Chrome, Safari, Opera */
-moz-column-gap: 30px; /* Firefox */
column-gap: 30px;
-webkit-column-rule: 2px outset #aaa; /* Chrome, Safari, Opera */
-moz-column-rule: 2px outset #aaa; /* Firefox */
column-rule: 2px outset #aaa;
}
.3col {
-webkit-column-count: 3; /* Chrome, Safari, Opera */
-moz-column-count: 3; /* Firefox */
column-count: 3;
-webkit-column-gap: 30px; /* Chrome, Safari, Opera */
-moz-column-gap: 30px; /* Firefox */
column-gap: 30px;
-webkit-column-rule: 2px outset #aaa; /* Chrome, Safari, Opera */
-moz-column-rule: 2px outset #aaa; /* Firefox */
column-rule: 2px outset #aaa;
}
</style>
Upvotes: 0
Reputation: 375
You can do by using bootstrap rather than writing too much CSS , here is the link of bootstrap https://getbootstrap.com/
Here is the code of 3 colums using bootstrap
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-sm-4" style="background-color:orange;">Hello</div>
<div class="col-sm-4" style="background-color:white;">Hello</div>
<div class="col-sm-4" style="background-color:green;">Hello</div>
</div>
</div>
</body>
Here the link how to use columns in bootstrap https://getbootstrap.com/docs/4.0/layout/grid/
Hope this will help you.
Upvotes: 1
Reputation: 272590
Simply add display:flex
to the container of the 3 divs :
#IARA {
width: 400px;
margin:0 auto;
}
body {
margin: 0 padding:0px;
}
#IARAlogo {
margin-top: 10px;
margin-right: 10px;
pointer-events: none;
float: right;
}
#checkout {
margin-top: 10px;
margin-left: 10px;
float: left;
pointer-events: none;
}
.CLEARTOPBAR {
clear: both;
display: flex;
margin: auto;
}
#Leftpanel {
background-color: orange;
width: 20%;
height: 50%;
padding: 25px;
}
#Middlepanel {
background-color: blue;
width: 35%;
height: 50%;
padding: 25px;
}
#Rightpanel {
background-color: pink;
width: 20%;
height: 50%;
padding: 25px;
}
<div id="IARA">
<img id="IARAlogo" src="iaraplaceholder.png" style="width:50px;height:40px;" draggable="false" unselectable: "on">
<img id="checkout" src="IARAcheckout.jpg" style="width:70px;height:60px;" draggable="false" unselectable: "on">
</div>
<div class="CLEARTOPBAR">
<div id="Leftpanel">
</div>
<div id="Middlepanel">
</div>
<div id="Rightpanel">
</div>
</div>
Or use float :
#IARA {
width: 400px;
margin:0 auto;
}
body {
margin: 0 padding:0px;
}
#IARAlogo {
margin-top: 10px;
margin-right: 10px;
pointer-events: none;
float: right;
}
#checkout {
margin-top: 10px;
margin-left: 10px;
float: left;
pointer-events: none;
}
.CLEARTOPBAR {
clear: both;
margin: auto;
}
#Leftpanel {
background-color: orange;
width: 20%;
height: 50%;
padding: 25px;
float:left;
}
#Middlepanel {
background-color: blue;
width: 35%;
height: 50%;
padding: 25px;
float:left;
}
#Rightpanel {
background-color: pink;
width: 20%;
height: 50%;
padding: 25px;
float:left;
}
<div id="IARA">
<img id="IARAlogo" src="iaraplaceholder.png" style="width:50px;height:40px;" draggable="false" unselectable: "on">
<img id="checkout" src="IARAcheckout.jpg" style="width:70px;height:60px;" draggable="false" unselectable: "on">
</div>
<div class="CLEARTOPBAR">
<div id="Leftpanel">
</div>
<div id="Middlepanel">
</div>
<div id="Rightpanel">
</div>
</div>
Or make them inline-block :
#IARA {
width: 400px;
margin:0 auto;
}
body {
margin: 0 padding:0px;
}
#IARAlogo {
margin-top: 10px;
margin-right: 10px;
pointer-events: none;
float: right;
}
#checkout {
margin-top: 10px;
margin-left: 10px;
float: left;
pointer-events: none;
}
.CLEARTOPBAR {
clear: both;
font-size:0;
margin: auto;
}
#Leftpanel {
background-color: orange;
width: 20%;
height: 50%;
padding: 25px;
display: inline-block;
font-size:initial;
}
#Middlepanel {
background-color: blue;
width: 35%;
height: 50%;
padding: 25px;
display: inline-block;
font-size:initial;
}
#Rightpanel {
background-color: pink;
width: 20%;
height: 50%;
padding: 25px;
display: inline-block;
font-size:initial;
}
<div id="IARA">
<img id="IARAlogo" src="iaraplaceholder.png" style="width:50px;height:40px;" draggable="false" unselectable: "on">
<img id="checkout" src="IARAcheckout.jpg" style="width:70px;height:60px;" draggable="false" unselectable: "on">
</div>
<div class="CLEARTOPBAR">
<div id="Leftpanel">
</div>
<div id="Middlepanel">
</div>
<div id="Rightpanel">
</div>
</div>
Upvotes: 1