White box at the bottom of a view - html

At the bottom of my page/view i got a white box that i can't remove. When i inspect elements there's no elements in that space (not even body or html)
I've tried to set body to height:100%, no paddings, margins etc but it made no difference.
Sorry if i've provided too little code, just shout if you need more.
Here's my CSS:
.header {
border: 0px;
margin: 0px;
padding: 0px;
padding-bottom: 10px;
background-color: black;
color: white;
display: block;
text-align: center;
}
h1 {
border: 0px;
margin: 0px;
padding: 20px;
}
.container-fluid {
height: auto;
border: 0px;
margin-left: auto;
margin-right: auto;
display: flex;
align-items: center;
justify-content: center;
background-color: black;
}
.btn btn-primary {
border: 20px;
}
.card {
align-items: center;
justify-content: center;
}
.card-body {
display: block;
padding: 0px;
}
.card-title > img {
margin-rigth: 5px;
}
.table {
font-size: 20px;
}
HTML:
#{
ViewData["Title"] = "Home Page";
}
<div class="header">
<h1>My Health Vision</h1>
<div class="col-md-3">
<button type="button" class="btn btn-primary btn-lg btn-block">Add new goal</button>
</div>
</div>
<div class="container-fluid">
<div class="card" style="width:400px">
<div class="card-body">
<h4 class="card-title"><img src="images/goal-icon.png" width="60" height="60" />My weigth goal</h4>
<table class="table">
<tbody>
<tr>
<th scope="row">Goal weigth</th>
<td>85</td>
</tr>
<tr>
<th scope="row">Deadline</th>
<td>2018-05-30</td>
</tr>
<tr>
<th scope="row">Current weight </th>
<td>90 <button type="button" class="btn btn-primary btn-sm">Update</button></td>
</tr>
<tr>
<th scope="row">Best weigth</th>
<td>87</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
Updated with HTML.

Instead of using:
height: 100%;
Use:
height: 100vh;

Related

div display flex text alling [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
hello the subject I couldn't do about css is this, how can i draw this in the image?
what I want to do is to copy the image with html and css.
I tried with display flex and but I couldn't
.channel-left {
display: flex;
flex-wrap: wrap;
margin: 0;
padding: 0;
list-style: none;
}
.channel-description {
width: auto !important;
}
<div class="channel-left mb-5">
<div class="channel-description">
<div class="channel-img">
<img src="img.jpg" class="img-circle">
</div>
<div class="channel-title">
<p>title</p>
<p>blabla</p>
</div>
</div>
<div class="channel-subs">
<button type="button" class="btn btn-large btn-outline-danger rounded"><i class="fa fa-heart"></i> Like</button>
</div>
</div>
.container {
display: flex;
background: black;
color: white;
align-items: center;
padding: 10px;
}
.description {
flex: 1 1 auto;
display: flex;
align-items: center;
}
.title {
padding: 10px;
}
.img {
border-radius: 90%;
overflow: hidden;
width: 50px;
height: 50px;
}
.subs {
flex: 0 1 auto;
}
<div class="container">
<div class="description">
<div class="img">
<img src="https://placekitten.com/50/50" class="img-circle">
</div>
<div class="title">
<p>title</p>
<p>blabla</p>
</div>
</div>
<div class="subs">
<button type="button" class="btn btn-large btn-outline-danger rounded">Like</button>
</div>
just give the simple flex css to parent, put all three items in same div and then give margin-left auto to last item to move it to right,
Rest style your typography and colors.
* {margin: 0; padding: 0; box-sizing: border-box;}
.channel-description {
display: flex;
align-items: center;
padding: 10px;
margin: 20px;
border: 1px solid #ddd;
}
.channel-subs {margin-left: auto;}
.channel-title {margin-left: 10px;}
<div class="channel-left mb-5">
<div class="channel-left mb-5">
<div class="channel-description">
<div class="channel-img">
<img src="img.jpg" class="img-circle">
</div>
<div class="channel-title">
<p>title</p>
<p>blabla</p>
</div>
<div class="channel-subs">
<button type="button" class="btn btn-large btn-outline-danger rounded"><i class="fa fa-heart"></i> Like</button>
</div>
</div>
</div>
Something like this would work:
.channel-left {
background: #1f2227;
border-radius: 15px;
color: white;
max-width: 400px;
padding-left: 20px;
padding-right: 20px;
}
.channel-left,
.channel-description {
display: flex;
align-items: center;
justify-content: center;
}
.channel-img {
flex-basis: 80px;
}
.channel-title,
.channel-description{
flex-basis: 100%;
}
<div class="channel-left mb-5">
<div class="channel-description">
<div class="channel-img">
<img src="img.jpg" class="img-circle">
</div>
<div class="channel-title">
<p>title</p>
<p>blabla</p>
</div>
</div>
<div class="channel-subs">
<button type="button" class="btn btn-large btn-outline-danger rounded"><i class="fa fa-heart"></i> Like</button>
</div>
</div>
I know you've already accepted an answer, however I want to post my own:
* {
font-family: sans-serif;
}
.channel-left {
display: flex;
flex-wrap: wrap;
margin: 0;
padding: 0;
list-style: none;
background: #222222;
padding-left: 10px;
padding-top: 10px;
border-radius: 10px;
}
.channel-description {
width: auto !important;
display: inherit;
flex-basis: 70%;
}
.img-circle {
border-radius: 50px;
border: 2px solid gray;
width: 50px;
}
.channel-info {
padding-left: 5px;
}
.btn-outline-danger {
background: #555555;
border-radius: 50px;
border: 2px solid gray;
height: 30px;
width: 150px;
color: white;
cursor: pointer;
margin-top: 25px;
}
.channel-subs {
display: inline-block;
float: right;
}
p {
color: white;
}
.channel-title {
font-weight: bold;
}
<div class="channel-left mb-5">
<div class="channel-description">
<div class="channel-img">
<img src="https://www.chiquita.com/wp-content/uploads/2019/12/Chiquita_Banana_Class_Extra_Yellow.jpg" class="img-circle">
</div>
<div class="channel-info">
<p class="channel-title">Title</p>
<p class="channel-desc">blabla</p>
</div>
</div>
<div class="channel-subs">
<button type="button" class="btn btn-large btn-outline-danger rounded"><i class="fa fa-heart"></i> Like</button>
</div>
</div>

How can I better format this div with buttons in it?

I've got three div's going here. One's a container then the other 2 are in place for some buttons! But it just doesn't look right. I'm not quite sure how to fix it
.button {
display: inline-block;
padding: 20px 30px;
font-size: 12px;
cursor: pointed;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #AB0002;
border: none;
border-radius: 15px;
}
.divButton {
height: 100%;
width: 100%;
background-color: #e4e4e4;
display: inline-block;
padding-bottom: 5px;
}
HTML:
<div class="divButton">
<p style="text-align: center; padding-top: 15px; color: black;">TEXT!</p>
<!--2 buttons "centered"-->
<div style="float: left; padding-left: 325px;">
<p style="padding-left: 72px;">Centered text above button</p>
<button class="button">TEXT</button>
<button class="button">TEXT</button>
</div>
<!--add spacing to move away from 2 buttons-->
<div style="float: left; padding-left: 125px;">
<p style="padding-left: 40px;">TEXT</p>
<button class="button" style="float: right;">TEXT</button>
</div>
</div>
jsfiddle: https://jsfiddle.net/3ar1L0zy/1/
And what i'm trying to achieve in paint form!
I would move away from using floats - css has moved on sufficiently so you shouldn't need to use them anymore.
Use flex instead:
.button {
display: inline-block;
padding: 20px 30px;
font-size: 12px;
cursor: pointed;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #AB0002;
border: none;
border-radius: 15px;
}
.divButton {
width: 100%; /* you don't really need this - divs are block elements which are 100% by default */
background-color: #e4e4e4;
padding: 0 20px 5px 20px;
box-sizing: border-box; /* as you have set the width, you need this to stop the div being 100% + 40px wide */
display:flex; /* this will align items in a row by default */
flex-wrap:wrap; /* this allows the content to wrap to multiple rows */
justify-content:space-between; /* this will push any content to either side of the row */
}
.divButton > p {
width:100%; /* make this take up full row */
}
.divButton > div {
text-align:center; /* use this to centre text - not padding */
}
<div class="divButton">
<p style="text-align: center; padding-top: 15px; color: black;">TEXT!</p>
<!--2 buttons "centered"-->
<div>
<p>Centered text above button</p>
<button class="button">TEXT</button>
<button class="button">TEXT</button>
</div>
<!--add spacing to move away from 2 buttons-->
<div>
<p>TEXT</p>
<button class="button">TEXT</button>
</div>
</div>
One other tip I would give you is try not to use inline styles - they become very hard to maintain and make it harder to debug too (and cause a lot larger files as you have to repeat code for styles instead of just using a class that can be used multiple times but programmed once)
Instead of use float: left on both div, you can use float right on the right one and remove the padding-left you set:
<div class="divButton">
<p style="text-align: center; padding-top: 15px; color: black;">TEXT!</p>
<!--2 buttons "centered"-->
<div style="float: left;">
<p style="padding-left: 72px;">TEXT</p>
<button class="button">TEXT</button>
<button class="button">TEXT</button>
</div>
<!--add spacing to move away from 2 buttons-->
<div style="float: right;">
<p style="padding-left: 40px;">TEXT</p>
<button class="button" style="float: right;">TEXT</button>
</div>
</div>
https://jsfiddle.net/3ar1L0zy/13/
you can achieve this too by using flexbox too. (better solution in my opinon)
HTML code:
<div class="divButton">
<h3 style="text-align: center; padding-top: 15px; color: black;">TEXT!</h3>
<!--2 buttons "centered"-->
<div class="divText">
<p style="padding-left: 72px;">TEXT</p>
<p style="padding-left: 40px;">TEXT</p>
</div>
<!--add spacing to move away from 2 buttons-->
<div>
<div class="divButtons">
<div>
<button class="button">TEXT</button>
<button class="button">TEXT</button>
</div>
<button class="button">TEXT</button>
</div>
</div>
</div>
CSS code:
.button {
display: inline-block;
padding: 20px 30px;
font-size: 12px;
cursor: pointed;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #AB0002;
border: none;
border-radius: 15px;
}
.button:hover {
background-color: #880002;
}
.divButton {
height: 100%;
width: 100%;
background-color: #e4e4e4;
display: inline-block;
padding-bottom: 5px;
}
.divText {
display: flex;
justify-content: space-around;
}
.divButtons {
display: flex;
justify-content: space-around;
}
<div class="divButton" style="text-align: center;">
<p style="text-align: center; padding-top: 15px; color: black;">TEXT!</p>
<div style="display: inline-block;">
<!--add spacing to move away from 2 buttons-->
<div style="float: right; display: inline-block; padding-left: 125px;">
<p style="text-align: center;">TEXT</p>
<button class="button" style="float: right;">TEXT</button>
</div>
<!--2 buttons "centered"-->
<div style="display: inline-block;">
<p style="text-align: center;">TEXT</p>
<button class="button">TEXT</button>
<button class="button">TEXT</button>
</div>
</div>
</div>
https://jsfiddle.net/3ar1L0zy/85/
I would recommend flexbox
.parent{
background: tomato;
width: 400px;
padding: 30px;
display: flex;
flex-direction: column;
}
.header{
background: yellow;
text-align: center
}
.body{
background: green;
width: 100%;
display: flex;
}
.body-item{
background: pink;
width: 50%;
text-align: center;
padding: 10px;
}
.blue{
background: blue; /* to make it easier to see */
}
.buttons{
display: flex;
flex-wrap: wrap; /* wrap items onto multiple lines if needed, from top to bottom*/
justify-content: space-evenly; /* items are distributed so that the spacing between any two items (and the space to the edges) is equal */
}
<div class="parent">
<h3 class="header">HEADER TEXT</h3>
<section class="body">
<div class="body-item">
<div class="text">Text</div>
<div class="buttons">
<button>Button</button>
<button>Button</button>
</div>
</div>
<div class="body-item blue">
<div class="text">Text</div>
<div class="buttons">
<button>Button</button>
</div>
</div>
</section>
</div>

Break <td>s in <tr> to two rows on small screens

I want to create layout like this:
Desktop
Mobile
but do not know how to achieve that. So far I have this:
<aside class="container-fluid" role="complementary">
<div class="modal-container ">
<div class="row">
<div class="col-xl-4 col-lg-4 col-md-4 col-sm-6 col-xs-12">
<h2>Name</h2>
<ul class="menu">
<li>Jack</li>
<li>John</li>
<li>James</li>
</ul>
</div>
<div class="col-xl-4 col-lg-4 col-md-4 col-sm-6 col-xs-12">
<h2>Surname</h2>
<ul class="menu">
<li>Sales</li>
<li>Admin</li>
<li>Sales</li>
</ul>
</div>
<div class="col-xl-4 col-lg-4 col-md-4 col-sm-12 col-xs-12">
<h2>Action</h2>
Connect
Connect
Connect
</div>
</div>
<table>
<tr>
<td>Jack</td>
<td>Sales</td>
</tr>
<tr>
<td>Connect</td>
</tr>
<tr>
<td>John</td>
<td>Admin</td>
</tr>
<tr>
<td>Connect</td>
</tr>
<tr>
<td>James</td>
<td>Sales</td>
</tr>
<tr>
<td>Connect</td>
</tr>
</table>
</div>
</aside>
What's the most sane way to achieve these layouts?
(Should it be table combined with flex? Is it ok to use BS grid for this?)
Your total bootstrap grid understanding here is wrong. Also I dont want to write the whole code for you - please understand the concept and implement the mobile layout.
Below is the grid correction for desktop, you have to add more bootstrap classes for making this more responsive.
You don't need tables for this, you can achieve both layouts completely with BS alone.
Run the below snippet, open it full-screen and resize your browser - you will notice the beauty of BS grid
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<aside class="container-fluid" role="complementary">
<div class="modal-container ">
<div class="row">
<div class="col-xs-12">
<h2 class='col-xs-4'> Name</h2>
<h2 class='col-xs-4'> Surname</h2>
<h2 class='col-xs-4'> Action</h2>
</div>
<div class="col-xs-12">
<span class='col-xs-4'>Jack</span>
<span class='col-xs-4'>Sales</span>
<input type="button" value='Connect' class='col-xs-4'/>
</div>
<div class="col-xs-12">
<span class='col-xs-4'>John</span>
<span class='col-xs-4'>Admin</span>
<input type="button" value='Connect' class='col-xs-4'/>
</div>
<div class="col-xs-12">
<span class='col-xs-4'>James</span>
<span class='col-xs-4'>Sales</span>
<input type="button" value='Connect' class='col-xs-4'/>
</div>
</div>
</div>
</aside>
Concept
Make <tr> into a flexbox on smaller screens
#media (max-width: 575.98px) {
.my-table tr {
display: flex;
flex-wrap: wrap;
}
.my-table tr>td:not(:last-child) {
flex: 1;
}
.my-table tr>td:last-child {
width: 100%;
}
}
It looks like
In total
body {
margin: 0;
}
header {
background: #00ADEE;
color: white;
height: 110px;
}
header h1 {
padding: 0.5rem;
margin: 0;
}
.my-table {
width: 50%;
margin-top: -50px;
margin-left: auto;
margin-right: auto;
background: white;
text-align: center;
border-collapse: separate;
border-spacing: 3rem 1.5rem;
border: 2px solid #E7E7E7;
}
.my-table th,
.my-table td {
padding: 0.5rem;
}
.my-table tr>td:last-child>a {
text-decoration: none;
display: block;
color: black;
padding: 0.5rem;
background: #E7E7E7;
}
#media (max-width: 575.98px) {
header h1 {
text-align: center
}
.my-table {
border-spacing: 1.5rem;
}
.my-table thead {
display: none;
}
.my-table tr {
display: flex;
flex-wrap: wrap;
text-align: center;
margin-bottom: 1.5rem;
}
.my-table tr>td:not(:last-child) {
flex: 1;
}
.my-table tr>td:last-child {
width: 100%;
}
}
<header>
<h1>Table Test</h1>
</header>
<table class="my-table">
<thead>
<th>Name</th>
<th>Surname</th>
<th>Action</th>
</thead>
<tbody>
<tr>
<td>Jack</td>
<td>Sales</td>
<td>Connect</td>
</tr>
<tr>
<td>John</td>
<td>Admin</td>
<td>Connect</td>
</tr>
<tr>
<td>James</td>
<td>Sales</td>
<td>Connect</td>
</tr>
</tbody>
</table>
(Change values according to your needs.)
With Bootstrap 3
Center table with offset. Use same concept as above.
body {
margin: 0;
}
header {
background: #00ADEE;
color: white;
height: 110px;
}
header h1 {
padding: 0.5rem;
margin: 0;
}
.my-table {
margin-top: -50px !important;
text-align: center;
background: white;
}
.my-table * {
border: none !important;
}
.my-table th {
text-align: center;
}
.my-table tr>td:last-child>a {
text-decoration: none;
display: block;
color: black;
background: #E7E7E7;
}
#media (max-width: 575.98px) {
header h1 {
text-align: center
}
.my-table thead {
display: none;
}
.my-table tr {
display: flex;
flex-wrap: wrap;
}
.my-table tr>td:not(:last-child) {
flex: 1;
}
.my-table tr>td:last-child {
width: 100%;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<header>
<h1>Table Test</h1>
</header>
<div class="row">
<div class="col-xs-6 col-xs-offset-3 col-sm-6 col-sm-offset-3">
<table class="my-table table">
<thead>
<th>Name</th>
<th>Surname</th>
<th>Action</th>
</thead>
<tbody>
<tr>
<td>Jack</td>
<td>Sales</td>
<td>Connect</td>
</tr>
<tr>
<td>John</td>
<td>Admin</td>
<td>Connect</td>
</tr>
<tr>
<td>James</td>
<td>Sales</td>
<td>Connect</td>
</tr>
</tbody>
</table>
</div>
</div>

Make a div non-scroll able

I have two div in side a row named sidenav and mainscreen. I have assigned sidenav 1 column and mainscreen 11 columns by bootstrap. Floowing is the output of the following.
I want to make sidenav non scrollable but mainscreen should be srollable. Many solutions suggest using position:fixed. I tried making the position of sidenav fixed but it ruins the style of whole page. Following is the output after using fixed position of sidenav.
following is html!
<div class="container-fluid" style="width: 100%; padding: 0">
<div class="row" style="width: 100%;margin: 0px">
<nav class="sidenav col-md-1">
<ul class="menu">
<li class="menu-item">
<img src="../../assets/images/Mask Group 7.svg" alt="Logo" width="75"height="75">
</li>
<li class="menu-item">
<a routerLink ="/connect" style="width: 32%;height: 50%">
<img src="../../assets/images/home.svg" alt="Home" width="100%" height="100%">
<span class="navtext">home</span>
</a>
</li>
<li class="menu-item">
<a routerLink ="/connect" style="width: 32%;height: 50%">
<img src="../../assets/images/accept-file-or-checklist.svg" alt="Home" width="100%" height="100%">
<span class="navtext">approval </span>
</a>
</li>
<li class="menu-item">
<a routerLink ="/connect" style="width: 32%;height: 50%">
<img src="../../assets/images/folded-text-document.svg" alt="Home" width="100%" height="100%">
<span class="navtext">document</span>
</a>
</li>
<li class="menu-item">
<a routerLink ="/connect" style="width: 32%;height: 50%">
<img src="../../assets/images/wukla_logo.svg" alt="Home" width="100%" height="100%">
<span class="navtext">wukla</span>
</a>
</li>
</ul>
</nav>
<div class="mainscreen col-md-11">
<div class="header">
<div class="inputs">
<div class="input-group">
<span class="input-group-btn" style="height:45px">
<button class="searchinputbtn btn btn-secondary" type="button" style="border-style: none;border-radius: 0">hate</button>
</span>
<input type="text" class="form-control" placeholder="Product name" style="border-style: none">
<span class="input-group-btn">
<button class="searchinputbtn btn btn-secondary" type="button" style="border-style: none;border-radius: 0">love</button>
</span>
</div>
<button class="uploadbtn btn btn-secondary" type="button" style="border-style: none;border-radius: 0">Upload Document</button>
</div>
</div>
<div class="mainbody">
<div class="itemstodisplay">
<div class="notification">
<div class="bodytext">pending signatures</div>
<div class="components">
<app-pendingdoc [requestid]="pendingdoc.requestid" [title]="pendingdoc.title"></app-pendingdoc>
<app-pendingdoc [requestid]="pendingdoc.requestid" [title]="pendingdoc.title"></app-pendingdoc>
<app-pendingdoc [requestid]="pendingdoc.requestid" [title]="pendingdoc.title"></app-pendingdoc>
<app-pendingdoc [requestid]="pendingdoc.requestid" [title]="pendingdoc.title"></app-pendingdoc>
</div>
</div>
<div class="alldocs">
<div class="bodytext">all documents</div>
<div class="components">
<app-paksigndocument></app-paksigndocument>
<app-paksigndocument></app-paksigndocument>
<app-paksigndocument></app-paksigndocument>
<app-paksigndocument></app-paksigndocument>
</div>
</div>
<div class="wukladocs">
<div class="bodytext">wukla documents</div>
<div class="components">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
and following is scss!
#ID {
overflow: hidden
}
.sidenav {
position: fixed;
padding: 0;
background-color: #e6e6e6 ;
display: flex;
flex-direction: column;
justify-content: flex-start;
height: auto;
}
.menu {
padding: 0px;
list-style: none;
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
}
.menu-item {
border-bottom: 1px solid #ffffff;
height: 10%;
display: flex;
flex-direction: column;
width: 100%;
justify-content: center;
align-items: center;
}
.mainscreen {
padding: 0;
height: 1450px;
}
.header {
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
//width: 1259px;
width: 100%;
height: 36%;
opacity: 0.58;
background-color: #8cd1bc;
}
.mainbody {
height: 64%;
background-color: #f6f6f6;
}
.input-group{
width: 100%;
}
.searchinputbtn {
height: 20px;
}
.uploadbtn {
margin-top: 42px;
padding-left: 30px;
padding-right: 30px;
border-radius: 2px;
background-color: #e6e6e6;
font-size: 16.8px;
font-weight: bold;
letter-spacing: -0.3px;
text-align: left;
color: #ffffff
}
.inputs {
width: 35%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.navtext {
font-size: 11px;
line-height: 0.95;
letter-spacing: -0.3px;
text-align: left;
color: #59626a;
}
.itemstodisplay {
width: 100%;
height: 100%;
}
.notification {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
height: 26%;
background-color: azure;
}
.bodytext{
margin-bottom: 20px;
margin-top: 50px;
font-size: 20px;
line-height: 0.53;
letter-spacing: -0.5px;
text-align: left;
color: #73c7af;
}
.alldocs{
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
height: 38%;
background-color: cornsilk;
}
.wukladocs {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
height: 38%;
background-color:floralwhite;
}
.components {
height: 80%;
width: 100%;
display: flex;
flex-direction: row;
align-items: flex-start;
justify-content: center;
}
can anybody help me making sidenav non-scroll able?
You can use position: fixed and stretch the div to the length of the whole page. This can be done with the following CSS:
div {
position: fixed;
top: 0;
bottom: 0;
}
Then you can make the mainscreen scrollable and keep the sidenav fixed.
Try this:
.navbar-fixed-left {
width: 140px;
position: fixed;
border-radius: 0;
height: 100%;
}
.navbar-fixed-left .navbar-nav > li {
float: none; /* Cancel default li float: left */
width: 139px;
}
refer this article for more:
Usefull Article

Rearranging the order of cells in a table for mobile

I am trying to change the order of the cells I have in a table on #mobile screen, but haven't had any luck.
My table on Mac width is a grid with different cell sizes, colors, font sizes etc., but on Mobile I want it to be a simple list separated by horizontal lines, with a link for each item. I managed to do this, but I'd also like to change the order in which the list appears.
Tried to add divs and order it that way but it didn't work. Any advice would be most welcome!
Here's my HTML and mobile CSS:
#mobile screen CSS
.situations {
table.situ {
margin-left: 0%;
}
tr {
display: block;
color: #161616 !important;
line-height: 1 !important;
border: none;
}
#frame {
height: 100px;
width: 100%;
}
td {
/* Behave like a "row" */
display: block;
background-color: #ffffff;
border: none;
border-bottom: 0.5px solid #161616;
position: relative;
padding-left: 2%;
text-align: center;
height: 60px;
width: $fullWidth;
font-size: 14px !important;
color: #161616 !important;
padding-top: 8%;
padding-bottom: 8%;
line-height: 1 !important;
}
td:before {
/* Now like a table header */
position: absolute;
/* Top/left values mimic padding */
top: 6px;
left: 6px;
width: 45%;
padding-right: 10px;
white-space: nowrap;
color: #161616 !important;
line-height: 1 !important;
border: none;
}
}
<section class="situations responsiveWidth center cinch2">
<div class="table"><table class="situ" id="frame" border="0" cellspacing="0" cellpadding="0">
<tr>
<div id="situ4"><td class="product1" height="33.333%" rowspan="2"><a class="label black" href="product1.html">Text</a></td></div>
<div id="situ6"><td class="product2" height="16.666%"><a class="label black" href="product2.html">Text</a></td></div>
<div id="situ3"><td class="product3" height="50%" rowspan="3"><a class="label black" href="product3.html">Text</a></td></div>
</tr>
<tr>
<div id="situ5"><td class="product4" height="16.666%"><a class="label black" href="product4.html">Text</a></td></div>
</tr>
<tr>
<div id="situ2"><td class="product5" height="33.333%" colspan="2" rowspan="2"><a class="label black big" href="product5.html">Text</a></td></div>
</tr>
<tr>
<div id="situ7"><td class="product6" height="16.666%"><a class="label black" href="product6.html">Text</a></td></div>
</tr>
<tr>
<div id="situ8"><td class="product7" height="16.666%"><a class="label black startout" href="product7.html" id="situ8">Text</a></td></div>
<div id="situ1"><td class="product8" height="33.333%" colspan="2" rowspan="2"><a class="label white big" href="product8.html">Text</a></td></div>
</tr>
<tr>
<div id="situ9"><td class="product9" height="16.66666%"><a class="label black" href="product9.html" id="situ9">Text</a></td></div>
</tr>
</table></div>
<br>
</section>
You could consider using divs instead of a table and have a flexbox for the rows. It's than easy to change the order of the columns.
.table {
display: table;
width: 100%;
}
.row {
display: flex;
justify-content: space-between;
width: 100%;
border-bottom: thin solid lightgray;
}
.cell {
display: table-cell;
padding: 0.5em;
}
.title {
order: 2;
}
.name {
order: 1;
}
.zip {
order: 4;
}
.place {
order: 3;
}
<div class="table">
<div class="row">
<div class="cell title">Title</div>
<div class="cell name">Name</div>
<div class="cell zip">Zip</div>
<div class="cell place">Place</div>
</div>
<div class="row">
<div class="cell title">Title</div>
<div class="cell name">Name</div>
<div class="cell zip">Zip</div>
<div class="cell place">Place</div>
</div>
<div class="row">
<div class="cell title">Title</div>
<div class="cell name">Name</div>
<div class="cell zip">Zip</div>
<div class="cell place">Place</div>
</div>
</div>