Bottom border of table won't show - html

I'm trying to get a table to show on my WP site and I'm just learning CSS, but when I create what I think should be right doesn't come out right. Only the outer right, left, and top border show.
.front {
border: 2px solid red;
}
I put that in the table class. I also tried adding another bottom-border, even by itself, nothing. Here's my table code, very simple. Just trying to learn to use CSS.
<table class="front">
<tbody>
<tr>
<td>test.</td>
<td>test.</td>
</tr>
<tr>
<td colspan="2">test.</td>
</tr>
</tbody>
</table>
I searched on here and tried this, but doesn't work (there were others things I found on here, but this one I remember):
table {
border-collapse: separate;
}
I should note that I use a CSS plugin to make it easier for me to add it to CSS. Haven't used it much, a simple hide which works fine. Not sure if this could have something to do with it, just some extra info that may help.

The problem is probably the height of the table or the container in which is placed.
Look at this fiddle and try setting the height of the table to 100% like this:
.front {
border: 2px solid red;
height: 100%;
}

Just apply the following CSS accordingly; this will fix your issue:
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
The problem is with the "box-size" being "100%", so the borders are pushed further. If you apply the CSS properties above to such elements, you won't have to face such issues.
Edit:
This will work on elements that span across the full width (-or full height) inside another.
So, it will work like this with either "width" or "height", but here's both:
CSS:
.spanBox
{
width:100%;
height:100%;
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
.redBorder
{
border: 2px solid red;
}
HTML:
<table class="spanBox redBorder"><tr><td>...</td></tr></table>

Related

No matter what I do, I can't get the table elements to touch

So I'm designing an org chart based on the table element and I have a problem. I'm using <hr> elements to create the connectors; however, I can't get the dead space inbetween elements to go away. I've spent the last hour trying to figure out how the hell to get it to work and I just can't seem to figure it out.
I've included a picture to show:
The other issue is more of a question I haven't really looked into but figured I'd ask anyway. How can I lock the height of my table items. I've locked the width just fine but I can't seem to lock the height to 70px.
And here is some choice code:
<table class="orgchart" cellspacing="0" cellpadding="0">
<tr>
<td></td><td></td><td></td><td></td><td></td><td></td><td class="item">Director</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>
</tr>
<tr class="divider"><td></td><td></td><td></td><td></td><td></td><td></td><td><hr width="1" size="20"></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>
<tr>
<td></td><td></td><td></td><td></td><td></td><td class="item">Assistant to the Director</td><td></td><td class="item">Deputy Director</td><td></td><td></td><td></td><td></td><td></td><td></td>
</tr>
And the CSS:
.orgchart td {
width: 70px;
height: 70px;
text-align: center;
overflow: hidden;
white-space: no-wrap;
}
.divider td {
height: 20px;
}
.item {
border: 2px solid black;
}
And here is the CodePen: http://codepen.io/jacob_johnson/pen/GpEjmm?editors=110
There's a margin all the way around the <hr>. Remove the top and bottom margins from the <hr>. All browsers apply default styling to elements, though not always the same. As a result you will see reset and normalize stylesheets used to improve visual consistency and development pains.
Updated Codepen with CSS below added.
hr {
margin: 0 auto;
}
If I was doing this project I would find a simple grid framework to layout with DIVs or more than likely I would create this chart as an inline SVG.

How to put fancy border around an image in html5?

I am making an html page in which I have put some pictures. Now I want to put some fancy borders around it. How do I do that? My code is:
<img src="award.gif">
When I run it, it comes out perfectly. But I need a border. I use the latest version of Google Chrome. Thanks.
You can use CSS rules to set border around the image, see the below link where you can see different CSS borders and you can generate cross-browser border CSS. I like this tool very much and this tool provides an intuitive preview to see how the border will look like-
http://www.cssmatic.com/border-radius
Like this,
css:
img {
border:1px solid #021a40;
}
The "Double Border":
img {
padding:1px;
border:1px solid #021a40;
}
For multiple images, you can class in each images, and css is here,
Simple Example
Another one Example
And for more about border and border-radius refer this Link
UPDATE:
FIDDLE
You can do this by using a instead because in matters of CSS this can be more versatile.
CSS
myImage {
background:url(path to image file goes here);
border: 1px solid #000000; //black border
//some width and height values
}
HTML
<div class="myImage"></div>
HTML
<div class="divimg">
<img src="award.gif">
</div>
CSS
.divimg {
border: 1px solid red; }
There are many ways of doing that, you can create a div and put the image inside the div and then, with css, create the border.
Another simple way is this:
img {
border-style:solid;
border-width:1px;
border-color:red;
}

Using box-sizing to create an inside border

I want to create an HTML table where each cell is clickable, and clicking on a cell adds a border to the single div within the cell. I want that div's border to exist entirely within the existing confines of the td that contains it, without resizing the table or its cells at all. I can't seem to make this happen correctly.
This previous question seems to address the same issue and points to some articles about the box-sizing CSS options. I have a fiddle where I tried to implement this without success: http://jsfiddle.net/YsAGh/3/.
* {
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
<table>
<tr>
<td><div>1</div></td>
<td><div>2</div></td>
<td><div>3</div></td>
</tr>
....
</table>
Here's what currently happens. The border causes the containing td to grow to accommodate the div's border.
How can I add the border to the div without it affecting the containing table?
Look at my JSFiddle.
You need to provide a width/height to your cells:
td {
// ...
width:33.3%;
height:33.3%;
}
How about using an inset box-shadow?
.selected {
box-shadow: inset 0px 0px 0px 2px red;
}
OK, since I've seen a some support for my response in the comments, here it as an answer :)
Presize your cell by adding a yellow 'hidden' border to the .unselected state:
CSS
.unselected {
background-color: yellow;
border: 2px solid yellow; // Presize with this yellow border
}
div {
..
line-height: 1; // Add line-height to regulate size (optional)
}
Codepen example.
Using table-layout to fix the width of cells and small padding in selected to prevent increasing height.
table {
table-layout: fixed;
}
.selected {
padding: 1px;
}
See JSFiddle

Table showing format

I just need to show my plain html table in which it shows only lines of rows and hide columns in it, so that the another person seeing it, thinks it as a table with one column, but actually it has multiple columns...I cant use colspan, as I need columns as itself...
Please help
thanks..
Turn the border off on your: <table border="0" class="thisTable">, and give it a class like the example. Then add the following lines to your CSS:
table.thisTable {
border-bottom:1px #000 solid;
// edit:
border-spacing:none; // you need this to take away spacing you still see
border-collapse:collapse; // you need this to take away spacing you still see
}
table.thisTable td {
border-top:1px #000 solid;
}
This will add a border at the top for each td and end the table off with a bottom border.
Hope this helps.
//edit:
Add a class to the first and last <td> of each <tr> and define the following in your CSS as well:
table.thisTable td.first {
border-left:1px #000 solid;
}
table.thisTable td.last {
border-right:1px #000 solid;
}
This will round the borders off nicely along the edges of the table.
Use CSS to style your table:
td {
border-bottom: 1px;
border-top: 1px; /* optional, you will have to play with the formatting */
border-left: none;
border-right: none;
}
This will give a top and bottom border to each data cell, which should do what you need it to. Play a little with the formatting to make sure you get it right.

How to create a table inner bevel in HTML/CSS?

I'm designing this forum layout where I come up with a nice design to draw the forum tables, however, I'm not sure that this can be easily done in HTML/CSS.
Before I continue to draw the whole layout, I need to know if this is achievable and how, otherwise, I'll have to ditch this effect and rethink things...
For instance, the design I currently have is this one:
The rows on this example have all the same height but this is just an example. The real table will actually have different row heights and the code needs to take that into account...
How can this be done?
CSS can do something like that very easily, provided you don't have to scale the gradient vertically as the table size increases. Below is an example you could use that would give you the effect you depicted above.
UPDATE: I somehow didn't see the bevels (I guess I have to blame it being too late at night and my vision being too blurry). I had to zoom in to really see them, but I've updated my solution to fit. You need to add an extra "div" tag to make this solution work, but it is possible, although I don't think it works too the extent that your image shows. It will work fairly decently though. Down below I include some jQuery script that will remove the need for an extra <div /> tag.
For markup, you'd use something like this:
<table cellspacing="0">
<tr><td class="side"><div class="bevel">lorem</div></td><td class="side"><div class="bevel">ipsum</div></td><td class="main"><div class="bevel">dolor sit amet, consectetur</div></td></tr>
<tr><td class="side"><div class="bevel">lorem</div></td><td class="side"><div class="bevel">ipsum</div></td><td class="main"><div class="bevel">dolor sit amet, consectetur</div></td></tr>
<tr><td class="side"><div class="bevel">lorem</div></td><td class="side"><div class="bevel">ipsum</div></td><td class="main"><div class="bevel">dolor sit amet, consectetur</div></td></tr>
</table>
And in your stylesheet you'd use something like this:
td {
border: 1px solid #777;
}
.bevel {
background: url('img.png') top left repeat-x;
margin: -1px;
border-top: 1px solid #fbfbfb;
border-left: 1px solid #fbfbfb;
border-right: 1px solid #bfbfbf;
border-bottom: 1px solid #e8e8e8;
}
.side {
width: 30px;
}
.main {
width: 170px;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
For the image, make it 1px wide. It will repeat itself to fit the width of the cell. If you want the gradient to stretch vertically, you're out of luck. CSS can not scale images, only repeat them. In order to make a vertically scaled background image, you'd need to either have nightmarish markup, or some sort of JavaScript to make it work.
To get rid of the <div /> tag soup, you can use jQuery to insert the tags so you don't clutter up your source. All you need to do is add an 'outerBevel' class to the <td /> tags instead, then call this jQuery script (if you're using jQuery. I'm sure other JavaScript APIs can do similar things):
$('.outerBevel').wrapInner('<div class="bevel"></div>');
For the layout, the standard HTML table tag does all that, and is also an appropriate use for it.
To get the desired border effect, take a look at the different CSS border options here: http://www.w3schools.com/css/css_reference.asp#border
You'll probably want to do something like this:
table#mytable td {
border-style: inset;
border-width: 3px; /* or whatever width you want */
}