I need to do few tables using display:table, and I trying get into BEM metodology the right way.
.b-table {
dispay: table;
width: 100%;
font-family: arial, sans-serif;
}
.b-table__cell, .b-table__header {
display: table-cell;
text-align: left;
padding: .6em;
}
.b-table__cell {
border: 1px solid #ddd;
}
.b-table__cell--half-wide {
width: 50%;
}
.b-table__cell--quarter-wide {
width: 25%;
}
.b-table__header {
background-color: orangered;
border: 1px solid red;
}
.b-table__row {
display: table-row;
width: 100%;
}
.b-table__row:nth-child(even) {
background-color: #eee;
}
<section class="sect1">
<div class="b-table">
<div class="b-table__row">
<div class="b-table__header b-table__cell--half-wide">Company</div>
<div class="b-table__header b-table__cell--quarter-wide">Contact</div>
<div class="b-table__header b-table__cell--quarter-wide">Country</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Alfreds Futterkiste</div>
<div class="b-table__cell">Maria Anders</div>
<div class="b-table__cell">Germany</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Centro comercial Moctezuma</div>
<div class="b-table__cell">Francisco Chang</div>
<div class="b-table__cell">Mexico</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Ernst Handel</div>
<div class="b-table__cell">Roland Mendel</div>
<div class="b-table__cell">Austria</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Island Trading</div>
<div class="b-table__cell">Helen Bennett</div>
<div class="b-table__cell">UK</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Laughing Bacchus Winecellars</div>
<div class="b-table__cell">Yoshi Tannamuri</div>
<div class="b-table__cell">Canada</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Magazzini Alimentari Riuniti</div>
<div class="b-table__cell">Giovanni Rovelli</div>
<div class="b-table__cell">Italy</div>
</div>
</div>
</section>
<section class="sect2">
<div class="b-table">
<div class="b-table__row">
<div class="b-table__header b-table__cell--half-wide">Company</div>
<div class="b-table__header b-table__cell--half-wide">Contact</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Alfreds Futterkiste</div>
<div class="b-table__cell">Maria Anders</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Centro comercial Moctezuma</div>
<div class="b-table__cell">Francisco Chang</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Ernst Handel</div>
<div class="b-table__cell">Roland Mendel</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Island Trading</div>
<div class="b-table__cell">Helen Bennett</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Laughing Bacchus Winecellars</div>
<div class="b-table__cell">Yoshi Tannamuri</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Magazzini Alimentari Riuniti</div>
<div class="b-table__cell">Giovanni Rovelli</div>
</div>
</div>
</section>
<section class="sect3">
<div class="b-table">
<div class="b-table__row">
<div class="b-table__header b-table__cell--half-wide">Company</div>
<div class="b-table__header b-table__cell--half-wide">Contact</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Alfreds Futterkiste</div>
<div class="b-table__cell">Maria Anders</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Centro comercial Moctezuma</div>
<div class="b-table__cell">Francisco Chang</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Ernst Handel</div>
<div class="b-table__cell">Roland Mendel</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Island Trading</div>
<div class="b-table__cell">Helen Bennett</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Laughing Bacchus Winecellars</div>
<div class="b-table__cell">Yoshi Tannamuri</div>
</div>
<div class="b-table__row">
<div class="b-table__cell">Magazzini Alimentari Riuniti</div>
<div class="b-table__cell">Giovanni Rovelli</div>
</div>
</div>
</section>
I can't get tables 100% width of page,
how to properly set margin-top different for every table with BEM,
.sect1 .sect2 .sect3 - are they BEM blocks and should have b- class prefix, maybe for margin-top,
3a. what methods do you use to set many different margins between repeated same elements,
is border and color should be modificators when all elements have the same properties?
P.S. i can't use table - in mobile i need different cell order and some of cell need to be expandable.
Related
How can I make my container to go down automatically of the page if it exceed the width of the page? The page background is in black if you look at the jsfiddle and it's size is 780px. All two credit cards are displaying over the page. Thanks.
My CSS as below:
<div style="width:780px;background:#000">
<div class="container">
<div class="sleeve">
<div class="credit-card">
<div class="card-company">West Frodo</div>
<div class="card-number">
<div class="digit-group">4141 7204 9012 0029</div>
</div>
<div class="card-expire"><span class="card-text">CVC</span> 321 <span class="card-text">Expires</span> 12/24</div>
<div class="card-holder">John P. Smith</div>
<div class="card-type">Debit card</div>
</div>
</div>
<div class="sleeve">
<div class="credit-card selected" style="background: #555">
<div class="card-company">West Frodo</div>
<div class="card-number">
<div class="digit-group">4234 1302 3798 0265</div>
</div>
<div class="card-expire"><span class="card-text">CVC</span> 321 <span class="card-text">Expires</span> 12/24</div>
<div class="card-holder">John P. Smith</div>
<div class="card-type">Debit card</div>
</div>
</div>
<div class="sleeve">
<div class="credit-card" style="background: #3B3">
<div class="card-company">West Frodo</div>
<div class="card-number">
<div class="digit-group">4812 0322 0517 2840</div>
</div>
<div class="card-expire"><span class="card-text">CVC</span> 321 <span class="card-text">Expires</span> 12/24</div>
<div class="card-holder">John P. Smith</div>
<div class="card-type">Debit card</div>
</div>
</div>
<div class="sleeve">
<div class="credit-card" style="background: #3B3">
<div class="card-company">West Frodo</div>
<div class="card-number">
<div class="digit-group">4812 0322 0517 2840</div>
</div>
<div class="card-expire"><span class="card-text">CVC</span> 321 <span class="card-text">Expires</span> 12/24</div>
<div class="card-holder">John P. Smith</div>
<div class="card-type">Debit card</div>
</div>
</div>
</div>
</div>
Here's my fiddle: http://jsfiddle.net/5gronvk1/1/
Update the following selectors in your CSS with the following:
.container {
height: 100%;
}
and
.sleeve {
display: inline-block;
margin: auto;
}
I can't get the colors to show up in chrome. I've tried switching the order of the files in <link> just in case that is the problem. I don't see any reason why the colors are'nt showing up in chrome.
.header {
background-color: white;
}
.body {
background-color: blue;
}
<div class="header">
<div class="container">
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4">
<div class="headertext">
<h1> ROBIN HOBB </h1>
</div>
</div>
<div class="col-md-4">
<div class="facebookbuttons"></div>
<div class="fantasy_text"></div>
</div>
</div>
</div>
</div>
<div class="body">
<div class="container"></div>
</div>
Your .body class DIV doesn't have any content. If you put some text into it, you see the blue background:
(and since the browser windows background is white by default, you won't see the white background on your .header DIV...)
.header {
background-color: white;
}
.body {
background-color: blue;
}
<div class="header">
<div class="container">
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4">
<div class="headertext">
<h1> ROBIN HOBB </h1>
</div>
</div>
<div class="col-md-4">
<div class="facebookbuttons"></div>
<div class="fantasy_text"></div>
</div>
</div>
</div>
</div>
<div class="body">
<div class="container">Here is some content</div>
</div>
.header {
background-color: white;
}
body {
background-color: blue;
}
<div class="header">
<div class="container">
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4">
<div class="headertext">
<h1> ROBIN HOBB </h1>
</div>
</div>
<div class="col-md-4">
<div class="facebookbuttons"></div>
<div class="fantasy_text"></div>
</div>
</div>
</div>
</div>
<div class="body">
<div class="container"></div>
</div>
I assume you are trying to change the entire page background color which needs to be done with a body { ... } selector not .body{ ... } as in this sample.
However, if the goal is to target the with a class of body your CSS is correct but there is nothing inside for content so it has a height of 0 by default. Add content like Johannes mentioned and it should work for you.
I need two rows of 4 words, in total 8 words, like this
I currently have my words like this
How can I make the words egg, beak, tea and milk go in a row beneath; Cat spoon meal and passport. like that?
This is my code..
body, html {
margin-left: 10%;
margin-right: 10%;
padding: 0px;
height: 100%;
font-family: georgia, "Comic Sans MS";
background-color: #f0f0f0;
}
header {
height: 5%;
border-bottom: thick solid grey;
}
.img {
width: 25%;
height: 30%;
background-color:#f0f0f0;
float: left;
}
.antwoord {
float: left;
width: 95%;
height: 25px;
background-color: white;
border-style: solid;
border-color: #000000;
border-width: 4px;
}
.move1 {
}
.move2 {
margin-top: 12.5%
}
.move4 {
margin-top: 19%
}
.move5 {
margin-top: 33.5%
}
.move6 {
margin-top: 20.8%
}
.move7 {
margin-top: 37.5%
}
.word, .word .tekst, .word p {
display: inline;
}
.word2, .word2 .tekst, .word2 p {
}
.tekst {
padding: 4.5%;
}
footer {
border-top: thick solid grey;
height: 5%;
}
.points {
float: right;
}
.container {
width: 100%;
height: 90%;
}
.igen {
font-size: 25px;
font-weight: bold;
}
.sprint {
float: right;
}
.copyright {
position: relative;
bottom: 20px;
left: 65px;
font-size: 10px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Words</title>
<link rel="stylesheet" href="css/style.css" media="screen" title="no title" charset="utf-8">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">
<script>
</script>
</head>
<body>
<header>
<span class="fa fa-refresh" style="font-size:25px;"></span><span class="igen"> igen</span>
<span class="points"><i class="fa fa-thumbs-o-up" style="font-size:24px"></i>Rigtige: 0 <i class="fa fa-thumbs-o-down" style="font-size:24px"></i>Forkerte: 0</span>
</header>
<div class="container">
<div class="img" id="img1">
<div class="plaatje" id="plaatje1"><center><img src="img/cat.jpg" alt="cat" width="50%;"></div>
<div class="move1"><div class="antwoord" id="antwoord1"></div></div>
</div>
<div class="img" id="img2">
<div class="plaatje" id="plaatje1"><center><img src="img/beak.jpg" alt="beak" width="50%;"></div>
<div class="move2"><div class="antwoord" id="antwoord2"></div></div>
</div>
<div class="img" id="img3">
<div class="plaatje" id="plaatje3"><center><img src="img/spoon.jpg" alt="spoon" width="50%;"></div>
<div class="move3"><div class="antwoord" id="antwoord3"></div></div>
</div>
<div class="img" id="img4">
<div class="plaatje" id="plaatje4"><center><img src="img/milk.jpg" alt="milk" width="50%;"></div>
<div class="move4"><div class="antwoord" id="antwoord4"></div></div>
</div>
<div class="img" id="img5">
<div class="plaatje" id="plaatje5"><center><img src="img/egg.jpg" alt="egg" width="50%;"></div>
<div class="move5"><div class="antwoord" id="antwoord5"></div></div>
</div>
<div class="img" id="img6">
<div class="plaatje" id="plaatje6"><center><img src="img/thee.jpg" alt="tea" width="50%;"></div>
<div class="move6"><div class="antwoord" id="antwoord6"></div></div>
</div>
<div class="img" id="img7">
<div class="plaatje" id="plaatje7"><center><img src="img/meel.jpg" alt="meel" width="50%;"></div>
<div class="move7"><div class="antwoord" id="antwoord7"></div></div>
</div>
<div class="img" id="img8">
<div class="plaatje" id="plaatje8"><center><img src="img/passport.jpg" alt="passport" width="50%;"></div>
<div class="move8"><div class="antwoord" id="antwoord8"></div></div>
</div>
<div class="answers">
<div class="word" id="word1">
<div class="tekst" id="tekst1"> <p>Cat</p> </div>
</div>
<div class="word" id="word2">
<div class="tekst" id="tekst2"> <p>spoon</p> </div>
</div>
<div class="word" id="word3">
<div class="tekst" id="tekst3"> <p>meal</p> </div>
</div>
<div class="word" id="word4">
<div class="tekst" id="tekst4"> <p>passport</p> </div>
</div>
<div class="word2" id="word5">
<div class="tekst" id="tekst5"> <p>egg</p> </div>
</div>
<div class="word2" id="word6">
<div class="tekst" id="tekst6"> <p>beak</p> </div>
</div>
<div class="word2" id="word7">
<div class="tekst" id="tekst7"> <p>tea</p> </div>
</div>
<div class="word2" id="word8">
<div class="tekst" id="tekst8"> <p>milk</p> </div>
</div>
</div>
<footer>
<img class="dansk" id="dansk" src="img/dansk2.jpg" alt="dansk" />
<img class="sprint" id="sprint" src="img/sprint2.png" alt="sprint" />
<center><span class="copyright"> ©2013 laerdansk / FC-Sprint² Leerbedrijf bronnen </span></center>
</footer>
</body>
</html>
if you want to keep you html structure you can use this example:
.answers .word, .answers .word2{
float: left;
padding: 3px;
width: 100px;
}
.answers .word2:nth-child(5){
clear:left;
color: red;
}
<div class="answers">
<div class="word" id="word1">
<div class="tekst" id="tekst1"> <p>Cat</p> </div>
</div>
<div class="word" id="word2">
<div class="tekst" id="tekst2"> <p>spoon</p> </div>
</div>
<div class="word" id="word3">
<div class="tekst" id="tekst3"> <p>meal</p> </div>
</div>
<div class="word" id="word4">
<div class="tekst" id="tekst4"> <p>passport</p> </div>
</div>
<div class="word2" id="word5">
<div class="tekst" id="tekst5"> <p>egg</p> </div>
</div>
<div class="word2" id="word6">
<div class="tekst" id="tekst6"> <p>beak</p> </div>
</div>
<div class="word2" id="word7">
<div class="tekst" id="tekst7"> <p>tea</p> </div>
</div>
<div class="word2" id="word8">
<div class="tekst" id="tekst8"> <p>milk</p> </div>
</div>
</div>
Notice that I colored with red your fifth element that breaks content in new row.
But I suggest you to wrap you row content in single container cause it's more maintainable and readable.
See the snippet below.
.my-row{
clear: both;
}
.answers .word, .answers .word2{
float: left;
padding: 3px;
width: 100px;
}
<div class="answers">
<div class="my-row"> <!-- ADDED WORD CONTAINER -->
<div class="word" id="word1">
<div class="tekst" id="tekst1"> <p>Cat</p> </div>
</div>
<div class="word" id="word2">
<div class="tekst" id="tekst2"> <p>spoon</p> </div>
</div>
<div class="word" id="word3">
<div class="tekst" id="tekst3"> <p>meal</p> </div>
</div>
<div class="word" id="word4">
<div class="tekst" id="tekst4"> <p>passport</p> </div>
</div>
</div>
<div class="my-row"> <!-- ADDED WORD CONTAINER -->
<div class="word2" id="word5">
<div class="tekst" id="tekst5"> <p>egg</p> </div>
</div>
<div class="word2" id="word6">
<div class="tekst" id="tekst6"> <p>beak</p> </div>
</div>
<div class="word2" id="word7">
<div class="tekst" id="tekst7"> <p>tea</p> </div>
</div>
<div class="word2" id="word8">
<div class="tekst" id="tekst8"> <p>milk</p> </div>
</div>
</div>
</div>
So here is my problem. I use some ui-grid on my interface to show information, but I would like to have 2 grid of 3 columns side by side (aligned vertically). So far, I haven't found exemple of it and i tried to code it, but without success. Is there someone here with better experience then me who knows how its possible? So far, that's what i thought about the solution :
<ul data-role="listview" data-inset="true" data-icon="false">
<li data-role="list-divider">
<div class="ui-grid-b" style="width: 50%">
<div class="ui-block-a">Header 1</div>
<div class="ui-block-b">Header 2</div>
<div class="ui-block-c">Header 3</div>
</div>
<div class="ui-grid-b" style="width: 50%; float: right">
<div class="ui-block-a">Header 1</div>
<div class="ui-block-b">Header 2</div>
<div class="ui-block-c">header 3</div>
</div>
</li>
</ul>
I just try to get two table side by side like this one:https://jsfiddle.net/8o39tqgz/1/
EDIT
Just tried display: inline, but it doesn't work on the same line... https://jsfiddle.net/s71zpcgs/
How about this?
<ul data-role="listview" data-inset="true" data-icon="false">
<li data-role="list-divider">
<div class="ui-grid-b" style="width: 50%; float: left">
<div class="ui-block-a column" >Header 1</div>
<div class="ui-block-b column" >Header 2</div>
<div class="ui-block-c column" >header 3</div>
</div>
<div class="ui-grid-b" style="width: 50%; float: left">
<div class="ui-block-a column" >Header 1</div>
<div class="ui-block-b column" >Header 2</div>
<div class="ui-block-c column" >header 3</div>
</div>
</li>
</ul>
And then at your css add this
.column{
width:33%;
float:left;
/* you can optionally set a fixed height */
}
I guess its not exactly what I wanted, but that will do it. Ty to #ezanker for the solution :
HTML
<div data-role="page" id="page1">
<div data-role="header">
<h1>My page</h1>
</div>
<div role="main" class="ui-content">
<ul data-role="listview" data-inset="true" data-icon="false" class="gridUL">
<li data-role="list-divider">
<div class="ui-grid-a bothGrids">
<div class="ui-block-a">
<table class="halfGrid" style="width: 98%" >
<thead>
<tr><th>header 1</th><th>header 2</th><th>header 3</th></tr>
</thead>
<tbody>
<tr><td>content 1</td><td>Some bigger content in this cell</td><td>content 3</td></tr>
<tr><td>content 1</td><td>content 2</td><td>content 3</td></tr>
</tbody>
</table>
</div>
<div class="ui-block-b ">
<table class="halfGrid" style="width: 98%">
<thead>
<tr><th>header 1</th><th>header 2</th><th>header 3</th></tr>
</thead>
<tbody>
<tr><td>content 1</td><td>content 2</td><td>content 3</td></tr>
<tr><td>content 1</td><td>content 2</td><td>content 3</td></tr>
</tbody>
</table>
</div>
</div>
</li></ul>
</div>
</div>
CSS
.halfGrid {
margin-left: 1%;
margin-right: 1%;
border-spacing: 0;
border-collapse: collapse;
}
.halfGrid td, .halfGrid th {
border: 1px solid #aaa;
padding: 4px;
text-align: center;
width: 33%;
font-weight: normal;
white-space: normal;
}
.halfGrid th {
font-weight: bold;
}
IMPORTANT EDIT
Actually, I got the idea of splitting the screen in two and wrap one table in each side and that work exactly as I wanted! Im so happy, I was working on it for many hours... Felt like running in circle, but its finally done! Here is the code :
HTML
<div class="wrap">
<div class="fleft">
<ul data-role="listview" data-inset="true" data-icon="false" style="min-width:350px">
<li data-role="list-divider">
<div class="ui-grid-b">
<div class="ui-block-a" style="width:33%">PN</div>
<div class="ui-block-b" style="width:34%">Amendment</div>
<div class="ui-block-c" style="width:33%">Designation</div>
</div>
</li>
<!-- Data found -->
<li>
<a href="javascript:alert('Hello world');">
<div class="ui-grid-b">
<div class="ui-block-a" style="width:33%">Info1</div>
<div class="ui-block-b" style="width:34%">Info2</div>
<div class="ui-block-c" style="width:33%">Info3</div>
</div>
</a>
</li>
</ul>
</div>
<div class="fright">
<ul data-role="listview" data-inset="true" data-icon="false" style="min-width:350px">
<li data-role="list-divider">
<div class="ui-grid-b">
<div class="ui-block-a" style="width:33%">PN</div>
<div class="ui-block-b" style="width:34%">Amendment</div>
<div class="ui-block-c" style="width:33%">Designation</div>
</div>
</li>
<!-- Data found -->
<li>
<a href="javascript:alert('Hello world');">
<div class="ui-grid-b">
<div class="ui-block-a" style="width:33%">Info1</div>
<div class="ui-block-b" style="width:34%">Info2</div>
<div class="ui-block-c" style="width:33%">Info3</div>
</div>
</a>
</li>
</ul>
</div>
</div>
CSS
.wrap
{
width: 100%;
overflow:auto;
padding:2px;
}
.fleft
{
float:left;
width: 50%;
}
.fright
{
float: right;
width: 50%;
}
Found solution in this post : Split page vertically using CSS and integrated the part of my code. Here is the jsfiddle : http://jsfiddle.net/G6N5T/1211/
You could nest two 3 column grids within one 2 column grid:
<ul data-role="listview" data-inset="true" data-icon="false" class="gridUL">
<li data-role="list-divider">
<div class="ui-grid-a bothGrids">
<div class="ui-block-a">
<div class="ui-grid-b halfGrid">
<div class="ui-block-a cell">header 1</div>
<div class="ui-block-b cell">header 2</div>
<div class="ui-block-c cell">header 3</div>
</div>
</div>
<div class="ui-block-b ">
<div class="ui-grid-b halfGrid">
<div class="ui-block-a cell">Header 1</div>
<div class="ui-block-b cell">Header 2</div>
<div class="ui-block-c cell">header 3</div>
</div>
</div>
</div>
</li>
</ul>
.halfGrid {
margin-left: 1%;
margin-right: 1%;
}
.halfGrid .cell {
border: 1px solid #aaa;
padding: 4px;
text-align: center;
}
Updated FIDDLE
I have the following html:
<div class="container">
<div class="row">
<div class="col-md-2">
<div class="phone-and-email">
<p>+44 (0)7950 123 456 info#example.co.uk</p>
</div>
</div>
<div class="col-md-10">
<div class="icons">
<div class="row">
<div class="col-md-4">
<img src="images/info.png" class="pull-left"/>
<p>How to buy</p>
</div>
<div class="col-md-4">
<img src="images/delivery.png" class="pull-left"/>
<p>Free Delivery</p>
</div>
<div class="col-md-4">
<img src="images/gift.png" class="pull-left"/>
<p>Gift Vouchers</p>
</div>
</div>
</div>
</div>
</div>
</div>
css:
.phone-and-email, .icons {
border-top: 2px black solid;
border-bottom: 2px black solid;
}
I can't make the left column the same height as the right, and I have tried about 5 different solutions. It does work using javascript but I'd rather use css if possible.
How it looks:
How it should look:
One possible solution is to make use of display table for the row and table-cell to achieve the equal height of both grid sections.
Check this bootply.
HTML:
<div class="container">
<div id="onerow" class="row">
<div class="col-md-2 sameheight">
<div class="phone-and-email">
<p>+44 (0)7950 123 456 info#example.co.uk</p>
</div>
</div>
<div class="col-md-10 sameheight icons">
<div>
<div class="col-md-4">
<img src="http://www.bootply.com/assets/i_lovebootstrap.png" class="pull-left">
<p>How to buy</p>
</div>
<div class="col-md-4">
<img src="http://www.bootply.com/assets/i_lovebootstrap.png" class="pull-left">
<p>Free Delivery</p>
</div>
<div class="col-md-4">
<img src="http://www.bootply.com/assets/i_lovebootstrap.png" class="pull-left">
<p>Gift Vouchers</p>
</div>
</div>
</div>
</div>
</div>
CSS:
.phone-and-email, .icons {
border-top: 2px black solid;
border-bottom: 2px black solid;
}
img{
height:20px;
width:20px;
}
#onerow{
display: table;
}
.sameheight {
float: none;
display: table-cell;
vertical-align: top;
}