Html column borders - html

How do I achieve the following look and feel using html and/or css?
I want to draw a border around column1.
Can this be done in a single table with a div or will I have to create a new table with a single td and multiple rows?

Hopefully this is what you need:
CSS:
.border1
{
border: 2px solid black;
border-bottom:0px;
}
.border2
{
border: 2px solid black;
border-bottom:0px;
border-top:0px;
}
.border3
{
border: 2px solid black;
border-top:0px;
}
table
{
border-collapse: collapse;
}
<table>
<tr>
<td>q</td>
<td class="border1">q</td>
</tr>
<tr>
<td>q</td>
<td class="border2">q</td>
</tr>
<tr>
<td>q</td>
<td class="border2">q</td>
</tr>
<tr>
<td>q</td>
<td class="border3">q</td>
</tr>
</table>
Note: There are other ways to do this but since you wanted to use a table here you go(no need for two tables!!).

You can do it without table:(to set items one each other use flex)
.wrap{
display:flex;
}
.wrap-container{
border:1px solid black;
text-align:center;
width:30%;
margin-right:5px;
}
.elem{
border:1px solid black;
margin:5px;
margin-left: 5.5%;
width:150px;
padding:5px;
}
.title{
}
<div class="wrap">
<div class="wrap-container">
<div class="title">Column1</div>
<div class="elem">value</div>
<div class="elem">value</div>
<div class="elem">value</div>
<div class="elem">value</div>
<div class="elem">value</div>
</div>
<div class="wrap-container">
<div class="title">Column1</div>
<div class="elem">value</div>
<div class="elem">value</div>
<div class="elem">value</div>
<div class="elem">value</div>
<div class="elem">value</div>
</div>
</div>

Here is a fiddle for you.
.option-wrapper {
border: 2px solid blue;
width: 150px;
text-align: center;
}
.option-title {
color: blue;
margin-top: 10px;
}
.options {
margin-top: 10px;
}
.option {
border: 1px solid grey;
margin: 10px;
padding: 6px 0px;
}
<div class="option-wrapper">
<div class="option-title">
column1
</div>
<div class="options">
<div class="option">
option 1
</div>
<div class="option">
option 1
</div>
<div class="option">
option 1
</div>
<div class="option">
option 1
</div>
</div>
</div>
I've created a table-less solution, hopefully, this is what you're looking for.

You can write code like this.
CSS:
<style>
body {
margin: 0px;
padding: 0px;
}
.wrapper {
border: 1px solid red;
padding: 10px;
width: 200px;
}
.wrapper>div {
border: 1px solid blue;
font-size: 14px;
margin-bottom: 10px;
}
.wrapper>div:last-child {
border: 1px solid blue;
font-size: 14px;
margin-bottom: 0px;
}
</style>
HTML:
<div class="wrapper">
<div>view1</div>
<div>view2</div>
<div>view3</div>
<div>view4</div>
<div>view5</div>
</div>

Related

CSS BODY is unexpectedly wider than expected on mobile devices

The page looks as expected on desktop browsers e.g. Firefox, etc. The problem is with display on mobile devices.
When displayed correctly, the dark background of the "BODY" of the page should appear only as a thin frame, with the white background of the "mainFrame" div appearing as central with all contents inside it.
I have tied to change the width of the "mainFrame" class to 100% but it didn't help.
What changes should be made to the css to allow correct display on not desktop and mobile devices browsers?
Please see the CSS and HTML below.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir='ltr'>
<head>
<style>
html, body{height:100%;text-align: center;background:#646464;}
body{padding:0px;margin:0px; text-align: center;}
.mainFrame{
width: auto;
min-height:100%;
height: 100%;
background: white;
border: 5px solid #CCCCCC;
margin:auto;
}
html>body .mainFrame {width:auto; height: auto;}
th{
text-align: center;
padding: 9px 0px 9px 0px;
background: #E8E8FF;
font: bold 12px TAHOMA;
color: #404040;
}
td {
font: 11px Tahoma;
background: #DFEFFF;
padding: 8px 5px 8px 3px;
}
td.blank{
padding: 12px 0px;
background: WHITE;
}
.logosmallContainer {
position: relative;
width: 960px;
top: 22px;
}
.logosmallContainer1 {
position: relative;
width: 720px;
top: 22px;
}
.logosmall {
float:right;
}
.jobtabs{
position: relative;
top:40px;
width: 720px;
}
.upperTabs{
position: relative;
font-size: 12px;
width: 720px;
clear:both;
}
.uprTabs {
width:120px;
text-align:center;
padding:0px;
font: 12px tahoma;
float:right;
}
.uprTabs a {
width:120px;
height: 30px;
line-height:30px;
background-color: #EEEEEE;
text-decoration: none;
border-top: 1px #F5F5F5 solid;
border-left: 1px #F5F5F5 solid;
border-bottom: 1px #F5F5F5 solid;
border-right: 1px #F5F5F5 solid;
}
html>body .uprTabs a {width:118px; display:table; }
.uprTabs a:hover{
background-color: #C3E2DB;
text-decoration: none;
border-top: 1px solid #31557f;
border-left: 1px solid #31557f;
border-bottom: 1px solid #E6E6E6;
border-right: 1px solid #E6E6E6;
}
.lowerTabs{
position: relative;
font-size: 12px;
width: 720px;
border-top: solid #007FC0 5px;
clear:both;
}
html>body .lowrTabs a {width:118px; display:table;}
.lowrTabs {
width:120px;
background-color: #EEEEEE;
text-decoration: none;
text-align:center;
font: 12px tahoma;
float:right;
height: 27px;
line-height:27px;
}
.lowrTabs a {
width:120px;
height: 25px;
line-height:25px;
background-color: #EEEEEE;
text-decoration: none;
border-top: 1px #F5F5F5 solid;
border-left: 1px #F5F5F5 solid;
border-bottom: 1px #F5F5F5 solid;
border-right: 1px #F5F5F5 solid;
float:right;
}
.lowrTabs a:hover{
background-color: #C3E2DB;
text-decoration: none;
border-top: 1px #31557f solid;
border-left: 1px #31557f solid;
border-bottom: 1px #E6E6E6 solid;
border-right: 1px #E6E6E6 solid;
}
.vMsg2 {
font: bold 22px arial;
position: relative;
top: 78px;
width: 720px;
text-align: center;
direction:rtl;
clear:both;
}
.vMain {
position: relative;
top: 113px;
width:620px;
direction:rtl;
clear:both;
}
.vMainJobs {
position: relative;
top: 30px;
width:620px;
direction:rtl;
clear:both;
}
.pgn1 {
width: 330px;
top:30px;
position: relative;
}
html>body .pgn1 {display:table;}
.pgnbx {
width: 30px;
height: 20px;
line-height:20px;
float:right;
text-decoration: none;
text-align:center;
}
html>body .pgnbx a {display:table;}
.pgnbx a{
width: 30px;
border-width: 1px;
border-color: #ffe #aaab9c #ccc #fff;
border-style: solid;
background: #FFF;
background: #CDF6ED;
}
.pgnbx a:hover{
width: 30px;
background: #B3E1D7;
border-color: #fff #ccc;
text-decoration: none;
}
.mainXJobs {
height:55px;
clear:both;
}
.ad728Y{
position: relative;
width:728px;
border-top: double thick #D3D3D3;
border-bottom: double thick #D3D3D3;
}
</style>
</head>
<body topmargin='0' leftmargin='0' >
<div class="mainFrame" align="center">
<div class="logosmallContainer1">
<div class="logosmall"><img border="0" src="media/small.jpg" alt="logo"></div>
<DIV class=adtop2>
</div>
</div>
<div class="jobtabs">
<div class="upperTabs">
<DIV class=uprTabs><A href="?Category6">Category 6</DIV>
<DIV class=uprTabs>Category 5</DIV>
<DIV class=uprTabs>Category 4</DIV>
<DIV class=uprTabs>Category 3</DIV>
<DIV class=uprTabs> Category 2</DIV>
<DIV class=uprTabs>Category 1</DIV>
</div>
<div class ="lowerTabs">
<DIV class=lowrTabs>Category 7</DIV>
<DIV class=lowrTabs>Category 8</DIV>
<DIV class=lowrTabs>Category 9</DIV>
<DIV class=lowrTabs>Category 10</DIV>
<DIV class=lowrTabs> Category 11</DIV>
<DIV class=lowrTabs>Category 12</DIV>
</div>
</div>
<div class='vMsg2'><H1>
GENERAL LIST
</H1></div>
<br><br><br><br><br><div class="ad300" id="ad"></div><div class='vMainJobs' dir='ltr'> <table border='0' width='100%' dir='ltr' cellspacing='1'>
<tr>
<th width='100%' colspan='2'>DETAILS</th>
</tr>
<tr>
<td width='18%'height='18' valign='top'>LOCATION </td>
<td height='18'>LONDON</td>
</tr>
<tr>
<td width='18%'height='18' valign='top'>LINK</td>
<td height='18'><a href='https://www.example.com'>https://www.example.com</a></td>
</tr>
</table>
<table border='0'>
<tr>
<td class='blank'>
<a href='#top'>top of page</a>
</td>
</tr>
</table>
</div>
<div class="pgn1">
<div class='pgnbx'>
<a href='?jpage=2'>2</a>
</div>
<div class='pgnbx'>
<a href='?page=3'>3</a>
</div>
<div class='pgnbx'>
<a href='?jpage=4'>4</a>
</div>
<div class='pgnbx'>
<a href='?page=5'>5</a>
</div>
<div class='pgnbx'>
<a href='?jpage=6'>6</a>
</div>
<div class='pgnbx'>
<a href='?page=7'>7</a>
</div>
<div class='pgnbx'>
<a href='?jpage=8'>8</a>
</div>
<div class='pgnbx'>
<a href='?page=9'>9</a>
</div>
<div class='pgnbx'>
<a href='?page=10'>10</a>
</div>
<div class='pgnbx'>
<a href='?jpage=11'>11</a>
</div>
<div class='pgnbx'>
<a href='?page=12'>12</a>
</div>
</div>
<div class="mainXJobs"> </div>
<DIV class="ad728Y"> PUT item "Classicus" here HERE</DIV>
<br><br><br>
</div>
</body>
</font>
</html>
The reason your body does not adjust is because you are assigning width using px. Try to change it to "%" or "vw". You can always assign a max-width or min-width if you want to put a limit on how much you want the width to be.
If you need to have the children adjust to the parent container, assign the width: 100%.
You have to use media query for mobile devices.
For example if I want to add background color for the device of maximum 600px, it will show body background color as
lightblue
after 600px it will be the default.
#media only screen and (max-width: 600px) {
body {
background-color: lightblue;
}
}

Div Misalignment Inside of table

I'm having some issues with lining up similarly sized divs inside a td Chrome inspector confirms pixel size is the same. Trying to do a scheduler demo. Any ideas how to fix the alignment issue would be great! thanks!
I'll admit the small picture doesn't look like much, but it's there and over the length of 24 hours, it's certainly looks off.
I've played with inspector for the last hour, but just can't find it!
My Html code snippet...
<table>
<tbody>
<tr>
<td class="text-right ">
<div class="time_label">6am</div>
<div class="time_label">7am</div>
<div class="time_label">8am</div>
<div class="time_label">9am</div>
<div class="time_label">10am</div>
<div class="time_label">11am</div>
<div class="time_label">12pm</div>
<div class="time_label">1pm</div>
<div class="time_label">2pm</div>
<div class="time_label">3pm</div>
<div class="time_label">4pm</div>
<div class="time_label">5pm</div>
<div class="time_label">6pm</div>
<div class="time_label">7pm</div>
<div class="time_label">8pm</div>
<div class="time_label">9pm</div>
</td>
<td class="area area1">
<div class="block block1"></div>
<div class="block block2"></div>
My Sass snippet, this is inside of a bootstrap row/col-md-12...
$booker-container-height: 618px;
$booker-table-margin: 10px;
$booker-height: $booker-container-height - $booker-table-margin;
.booker_wrapper {
box-shadow: 0 0 12px #888;
}
.booker {
table {
margin: $booker-table-margin;
height: $booker-height;
table-layout: fixed;
width: 100%;
background-color: #fff;
border-bottom: 1px solid #ddd;
}
.time_label {
height: $booker-height/16;
border-top: 1px solid #DDD;
border-left: 1px solid #DDD;
}
.block {
height: $booker-height/32;
border-left: 1px solid #DDD;
}
.area:last-child{
border-right: 1px solid #DDD;
}
.area>.block:first-child
{
border-top: 1px solid #DDD;
}
.area>.block:nth-child(even)
{
border-bottom: 1px solid #DDD;
}
.area>.block:nth-child(odd)
{
border-bottom: 1px solid #DDD;
}
}
You should used the amazing css property box-sizing: border-box; supporting by IE8 to! Then set the height's items of left column at the double of the right and an border-bottom for each, like:
html:
<table>
<tr>
<th>
<div>Hello</div>
<div>Heros</div>
</th>
<td>
<div>World</div>
<div>Toto</div>
<div>Batman</div>
<div>Superman</div>
</td>
</tr>
</table>
scss:
* {
#include box-sizing(border-box);
}
$dark: #202020;
table {
border: 1px solid $dark;
border-bottom: 0;
}
th {
div {
height: 60px;
border-bottom: 1px solid $dark;
border-right: 1px solid $dark;
}
}
td {
div {
height: 30px;
border-bottom: 1px solid $dark;
}
}
I made a codepen here: http://codepen.io/pik_at/pen/qEKKBy

Two div in a line and other two on the next line

i am try css to display div in line
this is my html
<body>
<div id="main">
<div id="div1">div1</div>
<div id="div2">div2</div>
</div>
<div id="main_new">
<div id="div1_new">div1_new</div>
<div id="div2_new">div2_new</div>
</div>
</body>
this is my css
#div1{
border: solid 1px #000000;
background-color: #0066CC;
float: left;
}
#div2{
border: solid 1px #000000;
background-color: #66CC00;
float: right;
}
JSfiddle
here i am set only first div sub two div in one line
but i want to set another two div same as this
div1_new is in below on div1
div2_new is in below on div2
thanks.
Try this fiddle
http://jsfiddle.net/J7mJX/47/
You need to apply a clearfix
.clearfix:after {
content: "";
display: table;
clear: both;
}
CSS for your html:
#div1, #div1_new {
border: solid 1px #000000;
background-color: #0066CC;
float: left;
}
#div2, #div2_new {
border: solid 1px #000000;
background-color: #66CC00;
float: right;
}
#main, #main_new {
overflow:hidden;
}
I think this is what you want.
Changed the id names to classes instead. I also put a br tag to separate the divs!
<body>
<div id="main">
<div class="divs1">div1</div>
<div class="divs1">div2</div>
</div>
<br/>
<div id="main_new">
<div class="divs2">div1_new</div>
<div class="divs2">div2_new</div>
</div>
</body>
(display:inline-block; is the code you probably were missing)
And here's the adjusted Css:
.divs1{
border: solid 1px #000000;
background-color: #0066CC;
width:70px;
display:inline-block;
}
.divs2{
border: solid 1px #000000;
background-color: #66CC00;
width:70px;
display:inline-block;
}
Here's a fiddle link to help:
http://jsfiddle.net/Anicefry/t3Lmw/
Is that what you want? http://jsfiddle.net/ugktn/
<body>
<div id="left-col">
<div>div1</div>
<div>div1_new</div>
</div>
<div id="right-col">
<div>div2</div>
<div>div2_new</div>
</div>
<div id="main_new">
middle text
</div>
</body>
Css:
body{
margin: 0;
}
#left-col{
border: solid 1px #000000;
background-color: #0066CC;
float: left;
}
#right-col{
border: solid 1px #000000;
background-color: #66CC00;
float: right;
}
Specify your desired width for all div.Include this in all
width:100px;
float:left;
Try to use less divs :-)
<!DOCTYPE html>
<html lang="en">
<head>
<title> Bla! </title>
<style type='text/css'>
div {width:50%; float:left}
div.divRed { background-color:red; }
div.divGreen { background-color:Green; }
</style>
</head>
<body >
<div class='divRed'> div1 </div>
<div class='divGreen'> div2 </div>
<div class='divGreen'> div1 new </div>
<div class='divRed'> div2 new </div>
</body>
</html>
Add a <div style="clear:both;"></div> before first container ends
DEMO
#main {
width:50%;
float:left;
}
#main_new {
width:50%;
float:right;
}
#div1{
border: solid 1px #000000;
background-color: #0066CC;
}
#div2{
border: solid 1px #000000;
background-color: #66CC00;
}
#div1_new{
border: solid 1px #000000;
background-color: red;
}
#div2_new{
border: solid 1px #000000;
background-color: yellow;
}
If you don't want to change your actual code and use css calculation do this in your css:
body{
margin: 0;
}
#main{
border: solid 1px #000000;
background-color: #0066CC;
float: left;
}
#main_new{
border: solid 1px #000000;
background-color: #66CC00;
float: right;
}
http://jsfiddle.net/J7mJX/51/
or if you want them side by side add a width to the body:
body{
margin: 0;
width: 113px;
}
#main{
border: solid 1px #000000;
background-color: #0066CC;
float: left;
}
#main_new{
border: solid 1px #000000;
background-color: #66CC00;
float: right;
}
http://jsfiddle.net/J7mJX/52/
Html:
<div id="main-div">
<div style="float:left">div1</div>
<div style="float:right">div2</div>
<div style="clear:both"></div>
</div>
<div id="main-div1">
<div style="float:left">div3</div>
<div style="float:right">div4</div>
<div style="clear:both"></div>
</div>
Css:
#main-div,.main-div1{
width:90px;
}

Unknown additional space on <div> top

I am creating a table madde with several divs, and I am having an extra space between the first row (styled as head) and the rest of them, only the fist two columns (divs). Here you can see very clear:
There is no style atribute causing this space, at least I am not able to find the reason of it.
I have reproduced it on jsfiddle and you can see that it also sets the extra space: DEMO
Here I bring HTML & Syle related code:
HTML:
<div class="tableWrap">
<div class="tableHeader">
<div class="contentColumn60">
<span class="tableHeaderText">Turno</span>
</div>
<div class="contentColumn20">
<span class="tableHeaderText">Tipo</span>
</div>
<div class="contentColumn10">
<span class="tableHeaderText">Editar</span>
</div>
<div class="contentColumn10">
<span class="tableHeaderText">Reactivar</span>
</div>
</div>
<div class="tableContent">
<div class="contentColumn60">
<span class="tableContentText">Mañana(17:00 - 21:00)</span>
</div>
<div class="contentColumn20">
<span class="tableContentText">Mañanas</span>
</div>
<div class="contentColumn10">
<div class="editIcon"></div>
</div>
<div class="contentColumn10">
<div class="discontinueIcon"></div>
</div>
</div>
<div class="tableContent">
<div class="contentColumn60">
<span class="tableContentText">Mañana(17:00 - 21:00)</span>
</div>
<div class="contentColumn20">
<span class="tableContentText">Mañanas</span>
</div>
<div class="contentColumn10">
<div class="editIcon"></div>
</div>
<div class="contentColumn10">
<div class="discontinueIcon"></div>
</div>
</div>
<div class="tableContent">
<div class="contentColumn60">
<span class="tableContentText">Mañana(17:00 - 21:00)</span>
</div>
<div class="contentColumn20">
<span class="tableContentText">Mañanas</span>
</div>
<div class="contentColumn10">
<div class="editIcon"></div>
</div>
<div class="contentColumn10">
<div class="discontinueIcon"></div>
</div>
</div>
STYLE:
.tableWrap{
width: 100%;
height:380px;
border:#ccc 1px solid;
border-radius:3px;
box-shadow: 0 1px 2px #d1d1d1;
margin: 10px;
background: -webkit-gradient(linear, left top, left bottom, from(#fbfbfb), to(#fafafa));
background: -moz-linear-gradient(top, #fbfbfb, #fafafa);
font-size:12px;
color:#666;}
.tableHeader{
height: 40px;
width: 100%;
background: -moz-linear-gradient(center top , #EDEDED, #EBEBEB) repeat scroll 0 0 rgba(0, 0, 0, 0);
border-bottom: 1px solid #E0E0E0;
border-left: 1px solid #E0E0E0;
border-top: 1px solid #FAFAFA;
display: inline-block;
font-weight: 600;
}
.tableHeaderText{
line-height: 40px;
padding: 0 10px;
}
.tableContent{
height: 40px;
width: 100%;
}
.tableContentText{
line-height: 40px;
padding: 0 0 0 20px;
}
.contentColumn60{
height: 40px;
width: 58%;
border-top:1px solid #fafafa;
border-bottom:1px solid #e0e0e0;
border-left:1px solid #e0e0e0;
display: inline-block;
}
.contentColumn20{
height: 40px;
width: 20%;
border-top:1px solid #fafafa;
border-bottom:1px solid #e0e0e0;
border-left:1px solid #e0e0e0;
display: inline-block;
}
.contentColumn10{
height: 40px;
width: 10%;
border-top:1px solid #fafafa;
border-bottom:1px solid #e0e0e0;
border-left:1px solid #e0e0e0;
display: inline-block;
}
.discontinueIcon{
width: 23px;
height: 23px;
background-size: 98%;
background-image: url(images/error.png);
background-repeat:no-repeat;
margin: 0 auto;
}
.editIcon{
width: 23px;
height: 23px;
background-size: 98%;
background-image: url(images/edit.png);
background-repeat:no-repeat;
margin: 0 auto;
}
Since the elements are inline-block, you could use vertical-align:top to align them as desired. It's worth noting that the default property value is baseline; this explains why they were behaving as they were. UPDATED EXAMPLE HERE
.contentColumn60 {
height: 40px;
width: 58%;
border-top: 1px solid #fafafa;
border-bottom: 1px solid #e0e0e0;
border-left: 1px solid #e0e0e0;
display: inline-block;
vertical-align: top;
}
.contentColumn20 {
height: 40px;
width: 20%;
border-top: 1px solid #fafafa;
border-bottom: 1px solid #e0e0e0;
border-left: 1px solid #e0e0e0;
display: inline-block;
vertical-align: top;
}
use overflow:hidden; for content column60,20,10 it works perfect
add a clearfix or use vertical-align:top and overflow:hidden
.contentColumn60:after {
content: "";
display: table;
clear: both;
}

Table grid using Div in HTML and CSS

I want to create a table grid using DIV (HTML & CSS only). I almost got into and still got some issues. I attached the sample image. I want the grid should be the same like this sample image. I attached the fiddle of what I created so far. Could you help somebody that what am doing and how can I improve to finish the table as same as the image?
HTML:
<div class="containerDiv">
<div class="rowDivHeader">
<div class="cellDivHeader">Recommendation</div>
<div class="cellDivHeader">Typical savings</div>
<div class="cellDivHeader">Improved SAP</div>
<div class="cellDivHeader">Improved EI</div>
<div class="cellDivHeader">Indicative cost</div>
<div class="cellDivHeader">Include</div>
<div class="cellDivHeader lastCell">Removal Reason</div>
</div>
<div class="rowDiv">
<div class="cellDiv">Room-in-roof-insulation</div>
<div class="cellDiv">93.0</div>
<div class="cellDiv">F : 29</div>
<div class="cellDiv">B : 89</div>
<div class="cellDiv">£1,500 - £2,700</div>
<div class="cellDiv">Checkbox</div>
<div class="cellDiv lastCell">Textbox</div>
</div>
</div>
CSS:
.containerDiv {
border: 1px solid #3697f6;
width: 100%;
}
.rowDivHeader {
border: 1px solid #668db6;
background-color: #336799;
color: white;
font-weight: bold;
}
.rowDiv {
border: 1px solid #668db6;
background-color: #cee6fe;
}
.cellDivHeader {
border-right: 1px solid white;
display: table-cell;
width:12%;
padding: 1px;
text-align: center;
}
.cellDiv {
border-right: 2px solid white;
display: table-cell;
width:10%;
padding-right: 4px;
text-align: center;
border-bottom: none;
}
.lastCell {
border-right: none;
}
sample image
Add display:table-row to the row div i.e .rowDivHeader & .rowDiv
& display:table to the main div .containerDiv
.containerDiv {
border: 1px solid #3697f6;
width: 100%; display:table
}
.rowDivHeader {
border: 1px solid #668db6;
background-color: #336799;
color: white;
font-weight: bold; display:table-row
}
.rowDiv {
border: 1px solid #668db6;
background-color: #cee6fe;
display:table-row
}
DEMO