This question already has an answer here:
Bootstrap 3 mixin multiple make-*-column
(1 answer)
Closed 8 years ago.
I am trying to create a page layout using bootstrap. My layout something similar to below image.
To archive for this I tried using bootstrap grid fuctions.
This is how my html look like
<div class="myLayout">
<div class="col-1">
</div>
<div class="col-2">
</div>
<div class="col-3">
</div>
</div>
In my less file
.myLayout {
.make-row();
.col-1 {
.make-md-column(6);
.make-sm-column(7);
.make-xs-column(12);
background: black;
height: 100px;
}
.col-2 {
.make-md-column(3);
.make-sm-column(5);
.make-xs-column(6);
background: blue;
height: 100px;
}
.col-3 {
.make-md-column(3);
.make-sm-column(0);
.make-xs-column(6);
.visible-lg-block;
background: red;
height: 100px;
}
}
UPDATE:
This is generating CSS from about Less
.col-1 {
position: relative;
float: left;
width: 100%;
min-height: 1px;
padding-left: 15px;
padding-right: 15px;
background: black;
height: 100px;
}
#media (min-width: 992px) {
.col-1 {
float: left;
width: 50%;
}
}
#media (min-width: 768px) {
.col-1 {
float: left;
width: 58.33333333%;
}
}
#media (min-width: 1200px) {
.col-1 {
height: 292px;
}
}
.col-2 {
position: relative;
float: left;
width: 50%;
min-height: 1px;
padding-left: 15px;
padding-right: 15px;
background: blue;
height: 100px;
}
#media (min-width: 992px) {
.col-2 {
float: left;
width: 25%;
}
}
#media (min-width: 768px) {
.col-2 {
float: left;
width: 41.66666667%;
}
}
#media (min-width: 1200px) {
.col-2 {
height: 292px;
}
}
.col-3 {
position: relative;
float: left;
width: 50%;
min-height: 1px;
padding-left: 15px;
padding-right: 15px;
display: none !important;
background: red;
height: 100px;
}
#media (min-width: 992px) {
.col-3 {
float: left;
width: 25%;
}
}
#media (min-width: 768px) {
.col-3 {
float: left;
width: 0%;
}
}
#media (min-width: 1200px) {
.col-3 {
display: block !important;
}
}
But this is not working for my expecting result. Can somebody tell me what is wrong in my code?
Thank you.
There shouldn't be any need for custom CSS/LESS code to make this happen. You can do it with the existing Bootstrap grid system classes.
BOOTPLY
div {
height: 200px;
}
.first {
background-color: black;
}
.second {
background-color: blue;
}
.third {
background-color: red;
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="first col-sm-6 col-xs-12"></div>
<div class="second col-lg-3 col-sm-6 col-xs-12"></div>
<div class="third col-lg-3 visible-lg-inline"></div>
Related
I am stuck trying to find an appropriate solution; without adding a lot of divs to my markup.
I need the content at the 1200px media query; to stay fixed at 1200 and in the centre. Which is working.
However, the row containers with background colours, shadows etc. to stay 100% of the width.
Any guidance on how best to solve this problem; would be very much appreciated.
* {
box-sizing: border-box; margin: 0; padding: 0;
}
input[type=text] {
font-size: 1.5rem; padding: 0 0.25em 0 1.2em; height: 4rem;
line-height: 4rem; width: 50vw; color: #333;
background: #f5f5f5; border: 1px solid #f5f5f5;
}
.head_sticky {
position: sticky; top: 0; z-index: 100;
}
#media only screen and (max-width: 599px) {
.col-m-1 { width: 16.67%; } .col-m-2 { width: 33.33%; } .col-m-3 { width: 50.00%; }
.col-m-4 { width: 66.67%; } .col-m-5 { width: 83.33%; } .col-m-6 { width: 100%; }
[class*='col-'] {
float: left; padding: 5px 16px 5px 0;
}
.search_form_cls {
height: 4.5rem; line-height: 4.5rem; font-size: 3rem;
color: black; border: none; background: transparent;
}
input[type=text] {
width: 75vw;
}
}
#media only screen and (min-width: 600px) {
.col-t-1 { width: 12.5%; } .col-t-2 { width: 25%; } .col-t-3 { width: 37.5%; }
.col-t-4 { width: 50%; } .col-t-5 { width: 62.5%; } .col-t-6 { width: 75%; }
.col-t-7 { width: 87.5%; } .col-t-8 { width: 100%; }
[class*='col-'] {
float: left; padding: 5px 24px 5px 0;
}
}
#media only screen and (min-width: 768px) {
.col-d-1 { width: 8.33%; } .col-d-2 { width: 16.66%; } .col-d-3 { width: 25% }
.col-d-4 { width: 33.33% } .col-d-5 { width: 41.66% } .col-d-6 { width: 50%; }
.col-d-7 { width: 58.33%; } .col-d-8 { width: 66.66%; } .col-d-9 { width: 75%; }
.col-d-10 { width: 83.33%; } .col-d-11 { width: 91.66% } .col-d-12 { width: 100%; }
[class*='col-'] {
float: left; padding: 5px 28px 5px 0;
}
}
#media only screen and (min-width: 1200px) {
.A3_row {
max-width: 1200px;
margin-left: auto;
margin-right: auto;
}
}
[class*='col-']:first-of-type {
padding-left: 16px;
}
[class*='col-']:last-of-type {
padding-right: 16px;
}
.A3_row {
display: flex; background-color: white;
}
.A3_row [class*='col-'] {
display: flex; align-items: center; flex-wrap: wrap;
}
.A3_row::after {
content: ""; clear: both; display: table;
}
.navigation_link
text-decoration: none; color: black;
}
<!DOCTYPE html>
<html lang='en'>
<head>
<title>Test</title>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id='head' class='A3_row shadow_bottom head_sticky'>
<div class='col-m-1 col-t-1 col-d-1'>
<span class='navigation_link'>☰</span>
</div>
<div class='col-m-2 col-t-2 col-d-2'>
LOGO
</div>
<div class='col-m-3 col-t-5 col-d-9 t-end'>
<input autocomplete='off' name='q' class='search_form_m' type='text' placeholder='Search' value='' maxlength='100'>
</div>
</div>
<div class='A3_row' style='background-color:blueviolet; font-size: 1.5em; font-weight: bold;'>
<div class='col-m-6 col-t-8 col-d-12'>Heading</div>
</div>
<div class='A3_row' style='background-color:blueviolet;'>
<div class='col-m-6 col-t-8 col-d-12' style="overflow-x: scroll; overflow-y: hidden; width: 100%;">Content</div>
</div>
<div class='A3_row' style='background-color:gold; font-size: 1.5em; font-weight: bold;'>
<div class='col-m-6 col-t-8 col-d-12'>Heading</div>
</div>
<div class='A3_row' style='background-color:gold;'>
<div class='col-m-6 col-t-8 col-d-12' style="overflow-x: scroll; overflow-y: hidden; width: 100%;">Content</div>
</div>
<div class='A3_row' style='background-color:lightseagreen; font-size: 1.5em; font-weight: bold;'>
<div class='col-m-6 col-t-8 col-d-12'>Heading</div>
</div>
<div class='A3_row' style='background-color:lightseagreen;'>
<div class='col-m-6 col-t-8 col-d-12' style="overflow-x: scroll; overflow-y: hidden; width: 100%;">Content</div>
</div>
<div class='A3_row'>
<div class='col-m-6 col-t-8 col-d-12' style='align-items: flex-start'>
<span>FOOTER</span>
</div>
</div>
</body>
</html>
A CSS-only solution using calc():
#media only screen and (min-width: 1200px) {
.A3_row {
width: 100%;
padding-left: calc((100% - 1200px) / 2);
padding-right: calc((100% - 1200px) / 2);
}
}
This width declaration makes the "row" 100% of the width of its containing block while the padding-* declarations ensure the "content" is 1200px.
See calc() (MDN)
Custom css (media queries) work for WordPress and inspector but not on live site.
I added the meta viewport tag to the HTML but still it's not working.
/* Media Queries */
/* small phones */
#media (max-width: 320px) {
#intro {
margin-left: 20px;
width: 85%;
}
.logo-image {
position: relative;
}
.logo-img {
display: none;
}
main {
width: 85%;
position: relative;
top: 0px;
}
.card {
width: 85%;
}
.card .card-image img {
width: 100%;
}
footer {
flex-direction: column;
text-align: center;
}
footer #left-footer {
flex: 1;
border-right: 0;
padding-left: 0;
}
footer #right-footer {
background: #eee;
color: black;
}
footer #right-footer a {
color: black;
}
footer #social-media-footer ul li:hover a .fa-instagram {
color: purple;
transition: 0.4s;
}
nav ul {
display: none;
}
#menu-icon {
display: flex;
}
#slideout-menu {
display: block;
text-align: center;
}
#searchbox {
display: none;
}
#blogpost {
width: 100%;
border-left: 0;
}
#sidebar {
display: none;
}
.comment-form {
width: 70%;
}
}
#media (max-width: 320px) {
#slideout-menu {
width: 65%;
}
#logo-img {
display: none;
}
#intro {
width: 95%;
height: 120vw;
}
#intro .logo-image {
width: auto;
height: auto;
max-width: 680px;
max-height: 750px;
position: relative;
right: 18px;
top: 50px;
}
main {
width: 95%;
margin-top: 0px;
}
.card {
width: 95%;
}
.card .card-image img {
width: 100%;
}
.logo-img {
display: none;
}
.card .card-description {
width: 100%
}
}
#media (min-width: 375px) and (max-width: 667px) and (-webkit-min-device-pixel-ratio: 2) {
#nav ul {
display: none;
}
#slideout-menu {
width: 65%;
}
#logo-img {
display: none;
}
#intro {
width: auto;
height: 120vw;
}
#intro .logo-image {
width: auto;
height: auto;
max-width: 800px;
max-height: 750px;
position: relative;
right: 5px;
top: 50px;
}
main {
width: 85%;
margin-top: 0px;
}
.card {
width: 95%;
}
.card .card-image img {
width: 100%;
}
.logo-img {
display: none;
}
.card .card-description {
width: 100%
}
nav ul {
display: none;
}
#menu-icon {
display: flex;
}
#slideout-menu {
display: block;
text-align: center;
}
#searchbox {
display: none;
}
#sidebar {
display: none;
}
#comments-section {
width: 140%;
}
}
#media (min-width: 720px) {
.logo-image {
display: flex;
}
main {
width: 95%;
}
.card {
width: 45%;
}
.card .card-image img {
width: 100%;
}
}
/* Tablet */
#media screen and (min-width: 668px) and (max-width: 768px) {
nav {
font-size: 2vw;
}
#logo-img {
height: auto;
width: auto;
max-width: 680px;
max-height: 750px;
}
#intro {
width: auto;
height: 100vw;
}
#intro .logo-image {
width: auto;
height: auto;
max-width: 1500px;
max-height: 1000px;
position: relative;
right: 10px;
top: 10px;
}
main {
width: 95%;
}
section {
flex-direction: column;
}
.card,
.card .Card Image img {
width: 100%;
}
footer {
flex-direction: column;
text-align: center;
}
footer #left-footer {
flex: 1;
border-right: 0;
padding-left: 0;
}
footer #right-footer {
background: #eee;
color: black;
}
footer #right-footer a {
color: black;
}
footer #social-media-footer ul li:hover a .fa-instagram {
color: purple;
transition: 0.4s;
}
#searchbox {
display: ;
}
}
#media screen and (min-width: 1200px) and (max-width: 1600px) and (-webkit-min-device-pixel-ratio: 1) {
nav ul {
display: flex;
list-style: none;
padding: 0 150px;
justify-content: space-around;
align-items: center;
height: 100%;
margin: 0;
}
#logo-img {
left: 30px
}
.logo-image {
display: flex;
}
main {
width: 95%;
}
.card {
width: 45%;
}
.card .card-image img {
width: 100%;
}
}
/* ----------- Retina Screens ----------- */
#media screen and (min-width: 1200px) and (max-width: 1600px) and (-webkit-min-device-pixel-ratio: 2) and (min-resolution: 192dpi) {
#logo-img {
left: 30px
}
.logo-image {
display: flex;
}
main {
width: 95%;
}
.card {
width: 45%;
}
.card .card-image img {
width: 100%;
}
#logo-img {
height: auto;
width: auto;
max-width: 680px;
max-height: 750px;
}
#intro {
width: auto;
height: 100vw;
}
#intro .logo-image {
width: auto;
height: auto;
max-width: 2500px;
max-height: 1000px;
position: relative;
right: 10px;
top: -200px;
}
main {
width: 95%;
}
section {
flex-direction: column;
}
.card,
.card .Card Image img {
width: 100%;
}
footer {
flex-direction: column;
text-align: center;
}
footer #left-footer {
flex: 1;
border-right: 0;
padding-left: 0;
}
footer #right-footer {
background: #eee;
color: black;
}
footer #right-footer a {
color: black;
}
footer #social-media-footer ul li:hover a .fa-instagram {
color: purple;
transition: 0.4s;
}
#searchbox {
display: ;
}
}
#media screen and (min-width: 1200px) and (max-width: 1600px) and (-webkit-min-device-pixel-ratio: 1) {
nav ul {
display: flex;
list-style: none;
padding: 0 200px;
justify-content: space-around;
align-items: center;
height: 100%;
margin: 0;
}
#logo-img {
left: 30px
}
}
Here is the HTML
">
/img/fuchsifuchs.png" alt="fuchsifuchs.png" class="fuchs-intro"/>
">
Gedichte
'post',
'posts_per_page' => 2,
);
$Gedichteposts = new WP_QUERY($args);
while($Gedichteposts->have_posts()) {
$Gedichteposts->the_post();
?>
">
"
alt="Card Image">
">
" class="btn-readmore"> weiter erkunden
</section>
<a href="<?php echo site_url('/projects'); ?>">
<h2 class="section-heading"> Kurzgeschichten</h2>
<section>
<?php
$args = array(
'post_type' => 'project',
'posts_per_page' => 2,
);
$project = new WP_QUERY($args);
while($project->have_posts()) {
$project->the_post();
?>
<div class="card">
<div class="card-image">
<a href=" <?php echo the_permalink(); ?>">
<img src="<?php echo get_the_post_thumbnail_url(get_the_ID()); ?>"
alt="Card Image">
</a>
</div>
<div class="card-description">
<a href="<?php the_permalink() ?>">
<h3><?php the_title(); ?></h3>
</a>
<p><?php echo wp_trim_words(get_the_excerpt(), 30); ?>
</p>
weiter erkunden
</div>
</div>
<?php }
wp_reset_query();
?>
</section>
<a href="<?php echo site_url('/about'); ?>">
<h2 class="section-heading"> Das bin ich</h2>
<section id="section-source">
<p>
Wenn Ihr mehr über mich und meine Geschichte erfahren wollt, schaut gerne hier rein. Ich erzähle euch, wie es zu diesem Blog gekommen ist und warum ihr rein schauen solltet.
</p>
Instagram Profil
</section>
A common issue I encounter when trying to write css from the WordPress admin panel is that my css is being overwritten. To solve this, you can try to match the specificity of the already existent css or if you are brave just add "!important" before the ";" of every rule.
Would recommend looking into specificity first, though.
I am new to responsive CSS. The code below is a template for a responsive html page. I would like it to normally have 25px margins, but for a cell phone there should not be any margins. I have tried as many combinations of adjustments as I can think of. For example I tried changing the left/right margins for column 1 and 12 for #media but that did not work.
What must I do ?
body { margin:25px; }
* { box-sizing: border-box; }
img {
width: 100%;
height: auto;
}
.row:after {
content: "";
clear: both;
display: table;
}
[class*="col-"] {
float: left;
padding-top: 15px;
width: 100%;
}
#media only screen and (min-width: 600px) {
.col-s-1 {width: 8.33%; }
.col-s-2 {width: 16.66%; }
.col-s-3 {width: 25%; }
.col-s-4 {width: 33.33%; }
.col-s-5 {width: 41.66%; }
.col-s-6 {width: 50%; }
.col-s-7 {width: 58.33%; }
.col-s-8 {width: 66.66%; }
.col-s-9 {
width: 75%;
padding: 15px;
}
.col-s-10 {width: 83.33%; }
.col-s-11 {width: 91.66%; }
.col-s-12 {
width: 100%;
padding:15px 0px 0px 0px;
}
}
#media only screen and (min-width: 768px) {
.col-1 {width: 8.33%; }
.col-2 {width: 16.66%; }
.col-3 {width: 25%; }
.col-4 {width: 33.33%; }
.col-5 {width: 41.66%; }
.col-6 {
width: 50%;
padding:0px 15px 15px 15px;
}
.col-7 {width: 58.33%; }
.col-8 {width: 66.66%; }
.col-9 {width: 75%; }
.col-10 {width: 83.33%; }
.col-11 {width: 91.66%; }
.col-12 {
width: 100%;
padding:15px;
}
}
html { font-family: arial; }
.header {
background-color: #9933cc;
color: #fff;
padding: 15px;
}
.menu ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.menu li {
padding: 8px;
margin-bottom: 7px;
background-color :#33b5e5;
color: #fff;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}
.menu li:hover { background-color: #0099cc; }
.aside {
background-color: #33b5e5;
margin-bottom: 15px;
padding: 15px;
color: #fff;
text-align: center;
font-size: 14px;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}
.footer {
background-color: #0099cc;
color: #fff;
text-align: center;
font-size: 12px;
padding: 15px;
}
<body>
<div class="header">
<h1>The Island of Crete</h1>
</div>
<div class="row">
<div class="col-3 col-s-3 menu">
<ul>
<li>The Flight</li>
<li>The City</li>
<li>The Island</li>
<li>The Food</li>
</ul>
</div>
<div class="col-6 col-s-9">
<h1>Chania - A great city</h1>
<p>Chania is the capital of the Chania region on the island of Crete. The city can be divided in two parts, the old town and the modern city.</p>
<!--<img src="img_chania.jpg" width="460" height="345">-->
</div>
<div class="col-3 col-s-12">
<div class="aside">
<h2>What?</h2>
<p>Chania is a city on the island of Crete.</p>
<h2>Where?</h2>
<p>Crete is a Greek island in the Mediterranean Sea.</p>
<h2>How?</h2>
<p>You can reach Chania airport from all over Europe.</p>
</div>
</div>
</div>
<div class="footer">
<p>Resize the browser window to see how the content respond to the resizing.</p>
</div>
</body>
From what I can see, you are using giving the body a margin of 25px at :
body { margin:25px; }
but then not changing it as per your requirements for smaller screens. You are correct in the need for using #media, but the implementation does not modify the margin further.
So basically, what needs to be done is :
/* Responsive layout - when the screen is less than 600px wide,
remove the margin
*/
#media screen and (max-width: 600px) {
body {
margin: 0;
}
}
Your issue is that the body is set to have a margin of 25px at the top of your stylesheet - therefore regardless of what you do with the column sizes, it will always use the 25px margin for the page as a whole.
In your media queries, insert the following:
body {
margin: 0;
}
As the media queries take place lower down the page than your initial assignment, it will override the previous margin - please note that this won't always work for higher end phones with high resolution screens (for example, the Galaxy S8 has a resolution width of 1440px).
I'm trying to build a page where 1 div will be chosen according to the page width. I've checked and rechecked my whole code from upside down and can't seen to figure out what's wrong.
For example, we have:
1
2
3
4
5
If the page is over 800 pixels width, then it will only display the div 5.
If the page is 320 pixels width, it will display the div 1, if 480 pixels width, then div 2, and so on...
Here:
<style> body { margin:0; color:#FFFFFF; font-size:large; }
/* */
#media screen and (max-width: 324px) {
#graficorelatorio1 {
overflow: hidden;
width: 254px;
height: 153px;
clear:both;
margin-left: auto;
margin-right: auto;
margin-bottom:1rem;
margin-top:1rem;
}
#graficorelatorio2, #graficorelatorio3, #graficorelatorio4, #graficorelatorio5 { display:none;
}
}
/* */
#media screen and (max-width: 490px) and (min-width: 325px){
#graficorelatorio2 {
overflow: hidden;
width: 324px;
height: 194px;
clear:both;
margin-left: auto;
margin-right: auto;
margin-bottom:1rem;
margin-top:1rem;
}
#graficorelatorio1, #graficorelatorio3, #graficorelatorio4, #graficorelatorio5 { display:none;
}
}
/* */
#media screen and (max-width: 624px) and (min-width: 491px) {
#graficorelatorio3 {
overflow: hidden;
width: 483px;
height: 228px;
clear:both;
margin-left: auto;
margin-right: auto;
margin-bottom:1rem;
margin-top:1rem;
}
#graficorelatorio1, #graficorelatorio2, #graficorelatorio4, #graficorelatorio5 { display:none;
}
}
/* */#media screen and (max-width:839px) and (min-width: 625px) {
#graficorelatorio4 {
overflow: hidden;
width: 624px;
height: 289px;
clear:both;
margin-left: auto;
margin-right: auto;
margin-bottom:1rem;
margin-top:1rem;
}
#graficorelatorio1, #graficorelatorio2, #graficorelatorio3, #graficorelatorio5 { display:none;
}
}
/**/
#media screen and and (min-width: 840px) {
#graficorelatorio5 {
overflow: hidden;
width: 841px;
height: 321px;
clear:both;
margin-left: auto;
margin-right: auto;
margin-bottom:1rem;
margin-top:1rem;
}
#graficorelatorio1, #graficorelatorio2, #graficorelatorio3, #graficorelatorio4 { display:none;
}
}
#mainrelatorio {
background-color: #134F5C;
overflow:hidden;
padding:0;
margin:0;
display:block;
}
</style>
<div id="mainrelatorio">
<!-- width="254" height="152.3110834864699" -->
<div id="graficorelatorio1">
1
</div>
<!-- width="323.0698621553885" height="193.6110834864699" -->
<div id="graficorelatorio2">
2
</div>
<!-- width="483" height="227.67577137343096"-->
<div id="graficorelatorio3">
3
</div>
<!-- width="623.5" height="288.84898929845417"-->
<div id="graficorelatorio4">
4
</div>
<!-- 841" height="321" -->
<div id="graficorelatorio5">
5
</div>
</div>
Try this one
.show-box {
width: 300px;
height: 300px;
background: crimson;
font-size: 80px;
text-align: center;
color: #fff;
line-height: 275px;
margin: 75px auto;
}
#media only screen and (min-width: 801px) {
.four, .three, .two, .one {
display: none;
}
}
#media only screen and (max-width: 800px) and (min-width: 621px) {
.five, .three, .two, .one {
display: none;
}
}
#media only screen and (max-width: 620px) and (min-width: 421px) {
.five, .four, .two, .one {
display: none;
}
}
#media only screen and (max-width: 420px) and (min-width: 321px) {
.five, .four, .three, .one {
display: none;
}
}
#media only screen and (max-width: 320px) {
.five, .four, .three, .two {
display: none;
}
}
<div class="show-box five">5</div>
<div class="show-box four">4</div>
<div class="show-box three">3</div>
<div class="show-box two">2</div>
<div class="show-box one">1</div>
It is working but you don't see it because the numbers are white with a white background.
Here is your code working with a black background color:
https://jsfiddle.net/2h41ny05/15/
#graficorelatorio1 {
overflow: hidden;
width: 254px;
height: 153px;
clear:both;
margin-left: auto;
margin-right: auto;
margin-bottom:1rem;
margin-top:1rem;
background-color: black;
}
I'm trying to build a simple grid system using SASS:
app.scss:
.row,
.col {
box-sizing: border-box;
}
.row:before,
.row:after {
content: " ";
display: table;
}
.row:after {
clear: both;
}
.col {
position: relative;
float: left;
}
.col + .col {
margin-left: 1.6%;
}
.col-1 {
width: 6.86666666667%;
}
.col-2 {
width: 15.3333333333%;
}
.col-3 {
width: 23.8%;
}
.col-4 {
width: 32.2666666667%;
}
.col-5 {
width: 40.7333333333%;
}
.col-6 {
width: 49.2%;
}
.col-7 {
width: 57.6666666667%;
}
.col-8 {
width: 66.1333333333%;
}
.col-9 {
width: 74.6%;
}
.col-10 {
width: 83.0666666667%;
}
.col-11 {
width: 91.5333333333%;
}
.col-12 {
width: 100%;
}
#media only screen and (max-width: 550px) {
.col-1,
.col-2,
.col-3,
.col-4,
.col-5,
.col-6,
.col-7,
.col-8,
.col-9,
.col-10,
.col-11,
.col-12 {
width: auto;
float: none;
}
.col + .col {
margin-left: 0;
}
}
// Body
body {
font-family: $default-font;
font-weight: normal;
font-size: 13px;
color: $text-default;
}
.app {
width: auto;
height: 100%;
border-style: outset;
border-width: 1px;
padding: 5px;
}
header-container.scss:
#import '../App/App.scss';
.header-container {
border-style: outset;
border-width: 1px;
border-radius: 5px;
padding: 10px;
}
My HTML:
<header className='header-container'>
<div className='row'>
<div className='col-2'>
<p>Person 1</p>
</div>
<div className='col-2'>
<p>Person 2</p>
</div>
</div>
</header>
Person 1 is appearing above Person 2, not at the side as I expect the grid to work. I cannot find out what's wrong, but I think I'm missing something basic.
You're missing .col on the column elements
.row, .col {
box-sizing: border-box;
}
.row:before, .row:after {
content: " ";
display: table;
}
.row:after {
clear: both;
}
.col {
position: relative;
float: left;
}
.col + .col {
margin-left: 1.6%;
}
.col-1 {
width: 6.86666666667%;
}
.col-2 {
width: 15.3333333333%;
}
.col-3 {
width: 23.8%;
}
.col-4 {
width: 32.2666666667%;
}
.col-5 {
width: 40.7333333333%;
}
.col-6 {
width: 49.2%;
}
.col-7 {
width: 57.6666666667%;
}
.col-8 {
width: 66.1333333333%;
}
.col-9 {
width: 74.6%;
}
.col-10 {
width: 83.0666666667%;
}
.col-11 {
width: 91.5333333333%;
}
.col-12 {
width: 100%;
}
#media only screen and (max-width: 550px) {
.col-1,
.col-2,
.col-3,
.col-4,
.col-5,
.col-6,
.col-7,
.col-8,
.col-9,
.col-10,
.col-11,
.col-12 {
width: auto;
float: none;
}
.col + .col {
margin-left: 0;
}
}
// Body
body {
font-family: $default-font;
font-weight: normal;
font-size: 13px;
color: $text-default;
}
.app {
width: auto;
height: 100%;
border-style: outset;
border-width: 1px;
padding: 5px;
}
.header-container {
border-style: outset;
border-width: 1px;
border-radius: 5px;
padding: 10px;
}
<header class='header-container'>
<div class='row'>
<div class='col col-2'>
<p>Person 1</p>
</div>
<div class='col col-2'>
<p>Person 2</p>
</div>
</div>
</header>
For now, your col-2 class doesn't make your div float:left;
Two possibilities:
You add the class col to your divs
You set all the class starting with col to float:left; You can do it this way: [class^="col"] { float:left; }
Well, I hadn't seen that you are using className and not class, so you can change it accordingly: [className^="col"] { float:left; }