add border but outside of button in Foundation [duplicate] - css

Quick question. I have a table, it has a border. When I add padding, it adds the padding from the inside of the table. Any way to make it add padding from outside the border?
Essentially, the table border lines should appear to be within its cell.

Im not 100% sure what you mean but you may want this.
HTML:
<table>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
</tr>
</table>
CSS:
body {
padding: 20px;
}
table {
width: 400px;
height: 400px;
outline:2px solid red;
outline-offset: -15px;
}
td {
border:2px solid blue;
}
Table only:
DEMO HERE
Cell only:
DEMO HERE
So here we are setting an outline and you can put an outline-offseton it. So this will bring it into the table if you use - value. Use it as a border but remember it doesn't count towards width or height.
Note: You can use this on each cell etc.

if i understand you right then you should use margin not padding.

Related

How can I keep the rightmost instead of leftmost contents of a TD?

I have a TD with contents often wider than the TD, a text-align of right, and an overflow-x of hidden. It is displaying the leftmost portion of its contents.
Let us say for the sake of argument that the cell content is "ABCDEFGHIJKLMNOPQRSTUVWXYZ", and the TD will show exactly six characters with a hidden overflow-x.
It is now showing "ABCDEF".
How can I show "UVWXYZ"?
You can use direction: rtl.
td {
border: 1px solid black;
max-width: 70px;
overflow-x: hidden;
direction: rtl;
/*text-align: right;*/
}
<table>
<tr>
<td>ABC</td>
<td>ABCDEFGHIJKLMNOPQRSTUVWXYZ</td>
</tr>
</table>

border on table cell - why does it stick out by 1px?

Why top/bottom border on <td> sticks out by 1px when table's container has certain width and when table is centered ?
Picture shows the problem:
HTML:
<body>
<table>
<tr>
<td style=" border-top:4px solid green;border-right:4px solid green;">data 1
<td>data 2
</table>
</body>
CSS:
table{
margin:10px auto;
border-collapse:collapse;
text-align:center;
line-height:30px;
}
td{
background-color:silver;
width:100px;
}
You are not closing the <td> and <tr>:
<td style=" border-top:4px solid green;border-right:4px solid green;">data 1
<td>data 2</td>
</tr>
Also, add the following CSS for:
Making borders even.
Making to use border-box layout.
CSS:
* {box-sizing: border-box;}
td {
background-color: silver;
width: 100px;
border: 4px solid silver;
}
Note: You might need to tinker a bit to get the right output. We can just advice you on the right direction.
Preview
Fiddle: https://jsfiddle.net/2vdf28xd/
It's because the width and height by default is calculated by the browser with
width = width + border left + border right + padding left + padding right
height = height + border top + border bottom + padding top + padding bottom
To avoid this, make sure the calculations are absolute with
td {
box-sizing: border-box;
}
Good luck!
I've figured out that this is a BUG in older versions of Firefox.
This behaviour does not happen in new FF version and other browsers.
You can add the following attribute for the table you might be using:
<table border="1">...</table>
Adding the border="1" attribute we can remove this 1px sticking out problem.

CSS: Add right floating content to a centered container

I am trying to append some content to a th container where the text is centered. I want the new content to be at the very right of the container, and keep the current text centered.
|--------content--------|
to
|--------content-------a|
where a is the new content.
I have seen a couple of similar posts, but can't find one that is relevant. I can easily do a float left , right, clear both to keep a on the right and content on the left, but I specifically want to keep content where it is. Also, I don't want content to be shifted to the left due to the presence of a if possible.
Try the following. Use position: relative on the th and then use absolute positioning for the appended element, b in my example.
table {
border: 1px dotted blue;
width: 100%;
}
table th {
position: relative;
}
table th div {
position: absolute;
top: 0;
right: 0;
border: 1px dotted gray;
color: red;
}
<table>
<tr>
<th>Centered Content <div>A</div></th>
</tr>
</table>
I think this is what you need.
<table width="200px" border="1">
<tbody>
<th> <span style=" text-align:center;">content </span><span style="float:right;">1</span>
</th>
</tbody>
</table>

CSS bottom Border Issue

I seem to be having issues with the either the border, or the box shadow appearing on my site.
If need be I will post the CSS for the areas that have the borders applied but it may be easier to just link you to my site: http://w11.zetaboards.com/GamesAndAnime/index/
Please remove below tr
<tr>
<td colspan="6" class="c_foot"></td>
</tr>
And add padding-bottom:10px to table (css.css line no:31) like below
table {
clear: both;
width: 100%;
padding-bottom: 10px;
}

td {position:relative; left} does not move the border

Please see the following example:
http://jsfiddle.net/6t6hq/7/
when I use td with position relative to move it,
it only move the content but not the border.
How can I move the border with the content?
<table>
<tr>
<td id="relativeTD">1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
</table>
<div id="expected">expected</div>​
<style>
td{
border:1px solid #000;
min-width:100px;
}
#relativeTD{
position:relative;
left:60px;
}
#expected{
border:1px solid #000;
position:relative;
left:60px;
}​
</style>
TD is of display: table-cell;!
So you can't move it using relative positioning. Instead, create another <div> inside the <td> and give border and stuff.
Instead, give position: absolute for the td. It works! Also, you need to give position: relative to the table.
Fiddle: http://jsfiddle.net/6t6hq/9/
Else, you can use margin-left too to the td.
You cannot move a single td border you need to move the whole table
Demo
table {
margin-left: 60px;
}
Either what you can do is give your table border: 0;, place a div inside your td
give it some width, border and position: relative with left: 60px; and you are good to go

Resources