How can I make the cell borders centered between the contents of the cells on either side?
I have a navigation bar I made with a table:
But I want the dividers to be centered like this:
How can I do this (without using javascript)?
JSFiddle
Html:
<table>
<tr>
<td>
<a href="something"><div>
something
</div></a>
</td>
<td>
<a href="something_else"><div>
Asdf
</div></a>
</td>
<td>
<a href="long_somthing"><div>
Extra Long Something
</div></a>
</td>
<td>
<a href="qwerty"><div>
qwerty
</div></a>
</td>
<td>
<a href="stuff"><div>
Things
</div></a>
</td>
</tr>
</table>
CSS:
table {
width:100%;
height:20px;
border-spacing:0px 0px;
background-color:#f6f6f6;
}
a {
color:#696969;
font-family:sans-serif;
text-decoration:none;
font-size:13pt;
outline:none;
}
div:hover {
color:#343434;
}
div:active, div:focus {
outline:none;
background-color:orange;
}
td {
border-left:2px groove rgba(147,147,147,0);
border-right:2px groove rgba(147,147,147,0);
text-align:center;
cursor:pointer;
}
td:hover {
border-left:2px groove rgba(147,147,147,.5);
border-right:2px groove rgba(147,147,147,.5);
color:#343434;
background-color:rgba(255,255,255,.5);
}
td:first-child {border-left:none;}
td:last-child {border-right:none;}
div {
width:100%;
height:100%;
padding:5px 0px;
}
Related
I have a table, but I would like to put my div tag in front of one too, but behind another, in the same table. I would like to put the div with the id "backDrop" behind the td with the id "td1", and the td with the id "menu", everything else should be behind the div
<table style="width:100%;border-collapse:collapse">
<tr style="z-index:1">
<td style="width:91.0vw;" id="header">
<h1>Tyler Silva E-Portfolio</h1>
</td>
<td onclick="openNav()"id="td1" style="background-color:#3953a5;z-index:initial;">
<img style="width:8vw;" id="logo" src="img/logo.png" onclick="openNav()"/>
</td>
<div id="backDrop" style="opacity:0" onclick="alert('hello')"></div>
</tr>
<tr>
<td>
<!--body-->
<h1 style="color:white">
hello world
</td>
<td id="nav" rowspan="2">
<div id="menu"><p>M<br />E<br />N<br />U<br /></p></div>
</td>
</tr>
<tr>
<td><!--footer--></td>
</tr>
</table>
and my css is
body
{
margin:0;
background-color:#55505c;
}
#header
{
height:8vw;
width:100%;
background-color:#77b6ea;
z-index:-1
}
h1
{
font-family:georgia;
font-size:3vw;
margin-top:1.5vw;
}
#logo
{
vertical-align:top;
padding:0;
}
td
{
padding:0
}
#nav
{
position:relative;
height:100vh;
background-color:#3953a5;
font-size:8vw;
z-index:100000;
}
#backDrop
{
position:fixed;
left:0;
top:0;
width:100vw;
height:100vh;
background-color:black;
z-index:initial;
opacity:0;
}
As #j08691 said placing div between a table row tag in invalid HTML. What you are after is something like this:
body
{
margin:0;
background-color:#55505c;
}
#header
{
height:8vw;
width:100%;
background-color:#77b6ea;
z-index:-1
}
h1
{
font-family:georgia;
font-size:3vw;
margin-top:1.5vw;
}
#logo
{
vertical-align:top;
padding:0;
}
td
{
padding:0
}
#nav
{
position:relative;
height:100vh;
background-color:#3953a5;
font-size:8vw;
z-index:100000;
}
#backDrop
{
position:fixed;
left:0;
top:0;
width:100vw;
height:100vh;
background-color:black;
z-index:99;
opacity:0;
border:1px solid #ffffff;
}
<div id="backDrop" style="opacity:0" onclick="alert('hello')"></div>
<table style="width:100%;border-collapse:collapse">
<tr>
<td style="width:91.0vw;" id="header">
<h1>Tyler Silva E-Portfolio</h1>
</td>
<td onclick="openNav()"id="td1" style="background-color:#3953a5;z-index:initial;">
<img style="width:8vw;" id="logo" src="img/logo.png" onclick="openNav()"/>
</td>
</tr>
<tr>
<td>
<!--body-->
<h1 style="color:white">
hello world
</h1>
</td>
<td id="nav" rowspan="2">
<div id="menu"><p>M<br />E<br />N<br />U<br /></p></div>
</td>
</tr>
<tr>
<td><!--footer--></td>
</tr>
</table>
The div has been placed placed above everything using z-index and position.
Is this what you were after?
When hovering over the image to prompt the text to appear, the text and banner flutter once you put the mouse over it. How can this be prevented.
Any help would be appreciated thanks.
Here's the sample. http://jsfiddle.net/a3mcmbby/
Html:
<div id="container-content">
<div id="design-background">
</div>
<div id="content">
<div id="table-content">
<table align="center">
<tbody>
<tr>
<td colspan="2" valign="bottom" style="font-family:ralewayregular; color: rgb(37,37,37); font-size: 110%; line-height: 150%;">
</td>
<td><img src="/images/layout/layoutImg6.png" alt="" width="310" height="182">
</td>
</tr>
<tr>
<td>
<img src="/images/layout/layoutImg4.jpg" alt="" width="304" height="194">
<h3>EXAMPLE</h3>
</td>
<td rowspan="2">
<img src="/images/layout/layoutImg5.jpg" alt="" width="311" height="406">
<h3>EXAMPLE</h3>
</td>
<td>
<img src="/images/layout/layoutImg1.jpg" alt="" width="308" height="195">
<h3>EXAMPLE</h3>
</td>
</tr>
<tr>
<td>
<img src="/images/layout/layoutImg3.jpg" alt="" width="304" height="195">
<h3>EXAMPLE</h3>
</td>
<td>
<img src="/images/layout/layoutImg2.jpg" alt="" width="308" height="195">
<h3>EXAMPLE</h3>
</td>
</tr>
<tr>
<td colspan="3" style="text-align:center; font-family: Semibold; color: rgb(165,97,11); font-size:300%;">Serving St. Catharines and Niagara Region</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
CSS:
#container-content{
position:relative;
margin: 0 auto;
width:100%;
min-height:700px;
background-color:#FFF;
}
#design-background{
position:absolute;
height:350px;
top:50%;
left:0px;
right:0px;
margin-top: -145px;
background: url('../images/background-dec.jpg');
}
#content{
position:relative;
margin: 0 auto;
left:0;
right:0;
width:980px;
}
#table-content{
position:absolute;
margin-top:-30px;
}
#table-content table tr td{
position: relative;
padding:8px;
}
#table-content table tr td h3{
display:none;
}
#table-content table tr td a:hover + h3{
color:#FFF;
display:block;
position: absolute;
z-index:10;
margin: auto;
top:0;
bottom:0;
left:8px;
right:10px;
font-family: ralewayregular;
height:50px;
background-color: rgba(0,0,0,0.7);
text-align: center;
padding-top:25px;
font-size: 200%;
}
http://jsfiddle.net/a3mcmbby/
try this
#table-content table tr td:hover h3{ #do something ... }
In your HTML, nest h3 within a, then adjust your CSS accordingly.
As it is now, h3 is being placed over top of the a tag when the a tag is hovered over. This prevents hovering from working so the hover status is removed. Then, it picks up the cursor hovering again because it is no longer covered - continuing in an endless loop.
When you display the h3, it is intercepting the hover in the underlying element, so it is no longer hovered. Then h3 is not displayed, the underlying element is hovered again , and so on
set
#table-content table tr td h3 {
pointer-events: none;
}
to avoid it
fiddle
i want to hide <th> such a way that happens when we give display:none but if i use this property i can't display it on mouse hover.i placed an up arrow inside the th to point something on hovering the table;
** When my table is not in hovered state those th remain hidden but there remain blank space which i do not want.**
I have tried using like this margin-top:-555px; and on hover margin-top:0 but does not work.
i do not want the red mark area but hover state on given link is ok for me.
please help.
jsfiddle
<div class="existing_items">
<table cellspacing="0">
<th class="pointer"colspan="2"><span>^</span></th>
<tr><th class="" colspan="2">Title</th></tr>
<tr><td class="leftname">name</td><td>name</td></tr>
<tr><td class="leftname">type</td><td>type</td></tr>
</table>
</div>
.existing_items{
background-color:green;
}
.existing_items table td{
text-align:center;
border-top:1px solid #eaeaea;
}
table:hover th.pointer{
visibility:visible;
}
table th.pointer{
color:red;
visibility:hidden;
font-size:20px;
}
.leftname{
border-right:1px solid #eaeaea;
}
I add position:inherit; in your table:hover th.pointer and it works;
You can try here:
http://jsfiddle.net/gkiwi/t7eecbzp/
Or
.existing_items{
background-color:green;
}
.existing_items table td{
text-align:center;
border-top:1px solid #eaeaea;
}
table:hover th.pointer{
visibility:visible;
top:-10px;
left:20px;
position:inherit;
}
table th.pointer{
color:red;
visibility:hidden;
font-size:20px;
overflow:hidden;
position:absolute;
top:-20px;
}
.leftname{
border-right:1px solid #eaeaea;
}
<div class="existing_items">
<table cellspacing="0">
<th class="pointer"colspan="2"><span>^</span></th>
<tr><th class="" colspan="2">Title</th></tr>
<tr><td class="leftname">name</td><td>name</td></tr>
<tr><td class="leftname">type</td><td>type</td></tr>
</table>
</div>
I would suggest to not use an extra (useless) <th> for this purpose. You could instead use a pseudo-element on your title <th>, as they seems highly related. See my example below:
.existing_items{
background-color:green;
}
.existing_items table td{
text-align:center;
border-top:1px solid #eaeaea;
}
table th.with-arrow {
position: relative;
}
table:hover th.with-arrow:after{
content: "^";
position: absolute;
left: 10px;
top: 0;
color: red;
font-size:20px;
}
.leftname{
border-right:1px solid #eaeaea;
}
<div class="existing_items">
<table cellspacing="0">
<tr><th class="with-arrow" colspan="2">Title</th></tr>
<tr><td class="leftname">name</td><td>name</td></tr>
<tr><td class="leftname">type</td><td>type</td></tr>
</table>
</div>
Introduction
I have this portion of HTML:
<!DOCTYPE HTML>
[...]
<table class="inv">
<tr>
<td id="i_1"></td><td id="i_2"></td><td id="i_3"></td><td id="i_4"></td><td id="i_5"></td>
<td class="dt" rowspan="5">
<div style="height:460px;position:relative">
<div class="st msg"></div>
<img src="content/images/site/inv.png"><br>
<a id="nm">USER INVENTORY</a><br>
<span class="desc">Contain tradable items of the user, click on an item on the left.</span><br>
<div style="text-align:right;padding-top:15px" class="bts"></div>
</div>
<div id="bot" style="display:none"><span class="bt i_b pp"><</span> <span class="bt i_b np">></span> <span style="font-weight:bold" id="pgs"></span></div>
</td>
</tr>
<tr>
<td id="i_6"></td><td id="i_7"></td><td id="i_8"></td><td id="i_9"></td><td id="i_10"></td>
</tr>
<tr>
<td id="i_11"></td><td id="i_12"></td><td id="i_13"></td><td id="i_14"></td><td id="i_15"></td>
</tr>
<tr>
<td id="i_16"></td><td id="i_17"></td><td id="i_18"></td><td id="i_19"></td><td id="i_20"></td>
</tr>
<tr>
<td id="i_21"></td><td id="i_22"></td><td id="i_23"></td><td id="i_24"></td><td id="i_25"></td>
</tr>
</table>
[...]
Linked to this CSS:
body{
font:16px Arial, Tahoma;
background-color:#222222;
margin:auto;
width:100%;
}
table{
border-collapse:collapse;
color:#FFF;
width:100%;
}
table td{
border:1px solid #FFFFFF;
vertical-align:top;
text-align:left;
padding:0px;
}
.inv{
table-layout:fixed;
}
.inv td:not(.dt){
width:100px;
height:100px;
text-align:center;
vertical-align:middle;
}
.inv td:not(.dt) > img{
max-width:100px;
max-height:100px;
cursor:pointer;
}
.inv td:not(.dt) > img:hover{
position:absolute;
z-index:100;
width:110px;
height:auto;
margin-top:-55px;
margin-left:-55px;
box-shadow:0px 0px 2px 1px #000000;
}
.inv .dt{
width:35%;
padding:10px;
}
.inv .dt img{
width:100%;
height:auto;
}
.inv .dt #desc{
font-size:12px;
color:#B8B6B4;
max-height:60px;
overflow:hidden;
display:inline-block;
}
.bt.i_b{
color:#FFFFFF;
}
.bt.i_b:hover{
background-color:#1B1B1B;
}
.det #nm{
font-size:20px;
font-weight:bold;
}
All the TDs inside the table are filled with images with this code:
for(var i = 0; i < ((inv.length < 25) ? inv.length : 25); i++){
$("td#i_"+(i + 1)).html('<img src="content/images/albums/'+inv[i]["song_id"]+'.png" title="'+inv[i]["song_name"]+'" id="'+(i+1)+'">');
}
The problem
Everything works fine, I get what I need (the table filled), but I get some sort of padding/margin at the bottom of every td with an image in it. Even if I have set width and height of the cells to 100px, in Firebug I can see a height of 103.5px, why this happens? I've read that it can be DOCTYPE causing it, but I can't remove it, id there an alternative solution?
Thanks.
"but I get some sort of padding/margin at the bottom of every td with an image in it."
Because img is an inline element, and thats why you see white space at the bottom, use this
table img {
display: block;
}
Now this will target all the images inside table element, so if you want the specific ones, use a class instead and assign like
table img.your_class {
display: block;
}
Demo
In the first image, I've used style="display: block;" and written inline, and not for the other two, so, you will see white space for the next two images but not the first one
I am trying to load an image using css styling and I have a red ridge border around it, but for some reason when I use css instead of html I get a odd small white border on the inside of the red ridge border with a white logo in the top left hand corner the little logo could be a tiny monitor I don't know how else to describe it. Does anyone know what is going on? I have other images loaded the same way with no problem.
Here is the CSS script
html
<table class="TopTableLeft">
<tr class="TopTableLeft">
<th class="thTopTableLeft1"><div class="tblheadr"> Symbol </div></th>
<th class="thTopTableLeft2"><div class="tblheadr2">Meaning</div></th>
</tr>
<tr>
<td class="ntscheduled"></td>
<td class="tdtext">Not Scheduled</td>
</tr>
<tr>
<td class="astris"></td>
<td class="tdtext"> Deactivated Tanks </td>
</tr>
<tr>
<td class="bltest"></td>
<td class="tdtext">Test Scheduled</td>
</tr>
<tr>
<td class="grntest"></td>
<td class="tdtext">Test In Process</td>
</tr>
<tr>
<td class="rdtest"></td>
<td class="tdtext">Test Late</td>
</tr>
</table>
<div id="pic" align="center" style="float:left;">
<img class="logo"/>
</div>
<div id="toptable2" align="center" style="float:none;">
<table class="TopTableRight">
<tr class="TopTableRight">
<th class="thTopTableRight1"><div class="tblheadr2">Meaning<div/></th>
<th class="thTopTableRight2"><div class="tblheadr""> Symbol </div></th>
</tr>
<tr>
<td class="tdtext">Not Scheduled</td>
<td class="ntscheduled"></td>
</tr>
<tr>
<td class="tdtext"> Deactivated Tanks </td>
<td class="astris"></td>
</tr>
<tr>
<td class="tdtext">Test Scheduled</td>
<td class="bltest"></td>
</tr>
<tr>
<td class="tdtext">Test In Process</td>
<td class="grntest"></td>
</tr>
<tr>
<td class="tdtext">Test Late</td>
<td class="rdtest"></td>
</TR>
</table>
css
table.TopTableLeft{
float:left; border:5px; border-style:outset; border-color:#FFFF00;
height:20px; width:23%; border-spacing:0; border-collapes:collapse;
}
table.TopTableRight{
float:right;border:5px; border-style:outset;border-color:#E80000; height:20px;
width:23%; border-spacing:0; border-collapes:collapse; vertical-align:top;
}
tr.TopTableLeft{
background-color:#595959;color:FFFF00;
}
tr.TopTableRight{
background-color:#595959;color:FFFF00;
}
th.thTopTableLeft1{
border:1px solid #FFFF00;font-size:12px; width:45;height:20;
}
th.thTopTableLeft2{
border:1px solid #FFFF00;font-size:12px; width:125;height:20;
}
th.thTopTableRight1{
border:1px solid #FFFF00;font-size:12px; width:125;height:20;
}
th.thTopTableRight2{
border:1px solid #FFFF00;font-size:12px; width:45;height:20;
}
div.tblheadr{
text-align:center; margin-bottom:-1px;
}
div.tblheadr2{
text-align:center; margin-bottom:-1px;
}
td.tdtext{
background-color:#000000; color:#FFFF00; border:1px solid #FFFF00;
font-family:'Arial'; font-size:12px; text-align:center; font-weight:bold;
}
td.ntscheduled{
background-color:#000000;color:FFFF00; border:1px solid #FFFF00;
background-image: url(../Images/Not-Scheduled.png); background-size:22px 24px;
width:25; height:24; background-repeat:no-repeat; background-position:center;
}
td.astris{
background-color:#000000;color:FFFF00; border:1px solid #FFFF00;
background-image: url(../Images/Gray-Astris3.png); background-size:22px 24px; width:25;
height:24; background-repeat:no-repeat; background-position:center;
}
td.bltest{
background-color:#000000;color:#FFFF00; border:1px solid #FFFF00;
background-image: url(../Images/Blue-Test.png); background-size:22px 24px; width:25;
height:24; background-repeat:no-repeat; background-position:center;
}
td.grntest{
background-color:#000000;color:FFFF00; border:1px solid #FFFF00;
background-image: url(../Images/Green-Test.png); background-size:22px 24px; width:22;
height:24; background-repeat:no-repeat; background-position:center;
}
td.rdtest{
background-color:#000000;color:FFFF00; border:1px solid #FFFF00;
background-image: url(../Images/Red-Test.png); background-size:22px 24px; width:22;
height:24; background-repeat:no-repeat; background-position:center;
}
img.logo{
float:none; margin-left:120px; margin-right:auto; margin-top:17px;
border:10px ridge #E80000; background-image: url(../Images/Logo.png);
background-size:199px 101px; width:199; height:101; background-repeat:no-repeat;
background-position:center;
}
Here is your soution:
img.logo {
margin-left:120px;
margin-right:auto;
margin-top:17px;
border:10px ridge #E80000;
background-image: url(../Images/Logo.png);
background-size:199px 101px;
width:199px;
height:101px;
background-repeat:no-repeat;
background-position:center;
}
Check out the Fiddle: Fiddle
Width and Height must be defined in px
Edit:
Move your img tag in div like
<div id="logo"><img/></div>
and then add its CSS:
#logo{
float:none;
margin-left:120px;
margin-right:auto;
margin-top:17px;
border:10px ridge #E80000;
background-color: blue;
background-image: url(../Images/Logo.png);
background-size:199px 101px;
width:199px;
height:101px;
background-repeat:no-repeat;
background-position:center;
}
Here is the working Fiddle: Fiddle
Your html is the problem. You have image with no source specified, but you put background instead. Browser is trying to read image but can't find source. Use image source and remove background or use span for example and leave background.