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.
Related
I have been having some trouble figuring this out so I have decided to include both my html and css in full this time.
I want my calendar section to be centered on the page below my header section which is to be fixed at the top of the page. I want my code to be dynamic so I am using translate to center my calendar.
When I view my code using IE or Edge the calendar is set in front of my header (centered horizontally but not vertically).
Could this have to do with my using positioning along with transforms?
HTML
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="stylesheet2.css"/>
<title></title>
<!--------------------------header--------------------------->
<div id="headerDiv">
<div id="titleDiv">
<p id= "titleText"> Title </p>
</div>
<ul id="navUL">
<li>Home</li>
<li>Browse</li>
<li>Stats</li>
<li>Calculator</li>
<li>Blaster</li>
</ul>
</div>
</head>
<!--------------------------calendar------------------------->
<body>
<div class="calendar">
<div>
<p class="month">December</p>
<table>
<tr>
<th class="cell">Sunday</th>
<th class="cell">Monday</th>
<th class="cell">Tuesday</th>
<th class="cell">Wednesday</th>
<th class="cell">Thursday</th>
<th class="cell">Friday</th>
<th class="cell">Saturday</th>
</tr>
<tr>
<td class="cell">29</td>
<td class="cell">30</td>
<td class="cell">1</td>
<td class="cell">2</td>
<td class="cell">3</td>
<td class="cell">4</td>
<td class="cell">5</td>
</tr>
<tr>
<td class="cell">6</td>
<td class="cell">7</td>
<td class="cell">8</td>
<td class="cell">9</td>
<td class="cell">10</td>
<td class="cell">11</td>
<td class="cell">12</td>
</tr>
<tr>
<td class="cell">13</td>
<td class="cell">14</td>
<td class="cell">15</td>
<td class="cell">16</td>
<td class="cell">17</td>
<td class="cell">18</td>
<td class="cell">19</td>
</tr>
<tr>
<td class="cell">20</td>
<td class="cell">21</td>
<td class="cell">22</td>
<td class="cell">23</td>
<td class="cell">24</td>
<td class="cell">25</td>
<td class="cell">26</td>
</tr>
<tr>
<td class="cell">27</td>
<td class="cell">28</td>
<td class="cell">29</td>
<td class="cell">30</td>
<td class="cell">31</td>
<td class="cell">1</td>
<td class="cell">2</td>
</tr>
</table>
</div>
</body>
</html>
CSS
/*-------------------header----------------------*/
body{
margin:0px;
}
#headerDiv{
position: fixed;
height:12%;
width:100%;
background-image:url("Gradient.png");
background-repeat:repeat-x;
text-align: center;
}
#titleDiv{
width: auto;
margin: auto 0;
}
#titleText{
color:#ff6600;
font-size:130%;
text-allign:center;
font-family:verdana,san serif;
}
#navUL{
list-style-type:none;
margin: auto 0;
padding:0;
border-top:1 solid;
border-right:1 solid;
border-left:1 solid;
width:100%;
}
#navUL li{
padding: .2em 1em;
color: #fff;
background-color: #036;
display:inline-block;
text-align:center;
}
/*------------------calendar--------------------*/
.calendar{
text-align:center;
float:left;
background-color:#ffeeff;
height:80%;
width:70%;
position:relative;
top:80%;
left:50%;
-ms-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%,-50%);
transform: translate(-50%,-50%);
}
.month{
padding-bottom:-20%;
font-size:260%;
text-align:center;
}
table,th,td{
border: 1px solid black;
text-align:center;
}
table{
text-align:center;
margin: 0 auto;
border-collapse: collapse;
width:100%
}
Your header should be in the body. If you want the calendar centered try either the following:
Include text-align:center in the body or..
Margin:auto in .calender or..
TranslateX(-50%) and margin-left: -35% or use pixels for width like 300px and then use margin-left: -150px which centers it.
If it doesnt work try absolute positioning. I hope this helps :).
I have a table in html.
The content of this table is text and an image. I would align the text in the top-left corner and the image in the middle (vertical-align).
I tried in this way:
CSS:
table td {border-collapse: collapse;}
#tabella {border: 1px solid black; text-align: left; vertical-align: top;}
#variante {vertical-align: middle;}
HTML:
<td id="tabella" style="padding:6px 8px; border-left: 1px solid #eeeeee;">text
<br>
<img id="variante" width="75" border="0" src="www.favetta.com/image.png">
</td>
But in this way I obtain all (text and image) aligned in the top-left corner of the cell.
Any suggestion?
Are you doing this for an email? If so inline styling is fine (although won't work in all email clients so have a default.
If email do something like...
<table>
<tr>
<td align="center">
<table width="100%">
<tr>
<td align="left">This is text</td>
</tr>
</table>
<br/><br/>
<img src="http://s27.postimg.org/fs9k8zewj/cow1.png">
<br/><br/><br/><br/>
</td>
</tr>
<table>
It looks crude but some browsers and email clients will ignore 'height='. This is purely what Ive found from years of email templating.
If not email, try and avoid tables - but if you can't then try something like...
<table>
<tr>
<td class="content">
This is text
<img src="http://s27.postimg.org/fs9k8zewj/cow1.png">
</td>
</tr>
<table>
css
table{
border:1px solid grey;
width:100%;
}
.content{
text-align:left;
}
.content img{
width:75px;
vertical-align:middle;
transform: translate(-50%, -50%);
margin: 100px 50% 50px 50%;
}
https://jsfiddle.net/qbss1f0t/
Here is a simple example:
table{
border:1px solid #000;
}
table tr{
height:200px;
}
table td{
width:200px;
text-align:center;
}
.textNode{
text-align:left;
padding:0;
margin:0;
vertical-align:top;
}
.imgNode img{
width:75px;
margin: auto;
}
<table>
<tr>
<td class="textNode">This is text</td>
<td class="imgNode"><img src="http://s27.postimg.org/fs9k8zewj/cow1.png"></td>
</tr>
<table>
Here is a fiddle
This should get you to where you want.
Side Note: inline styling is not a good practice.
Use this may help you
<table width="100%">
<tr>
<td id="tabella" style="padding:6px 8px; border-left: 1px solid #eeeeee;">text</td>
<td><img id="variante" width="75" border="0" src="www.favetta.com/image.png"></td>
</tr>
<table>
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 making a website and I decided to fire up Internet Explorer to check out if everything works. To my surprise, it all pretty much does. That being said, a table that I have in place does not look right at all. This is the HTML of the table:
<div id="stats">
<center>
<table style="width:100%;">
<tr>
<td id="name">Health:</td>
<td class="border" id="color"><font color="#0451ff">380</font><font color="#e81123">(+75)</font></td>
<td id="name">Health per 5:</td>
<td id="color"><font color="#7fba00">4.85</font><font color="#e81123">(+0.5)</font></td>
</tr>
<tr>
<td id="name">Mana:</td>
<td class="border" id="color"><font color="#0451ff">250</font><font color="#7fba00">(+50)</font></td>
<td id="name">Mana per 5:</td>
<td id="color"><font color="#7fba00">7.1</font><font color="#7fba00">(+0.75)</font></td>
</tr>
<tr>
<td id="name">Attack Damage:</td>
<td class="border" id="color"><font color="#e81123">47</font><font color="#7fba00">(+3.2)</font></td>
<td id="name">Attack Speed:</td>
<td id="color"><font color="#e81123">0.604</font><font color="#7fba00">(+1.68)</font></td>
</tr>
<tr>
<td id="name">Armor:</td>
<td class="border" id="color"><font color="#e81123">15.5</font><font color="#7fba00">(+4)</font></td>
<td id="name">Magic Resistance:</td>
<td id="color"><font color="#0451ff">30</font><font color="#0451ff">(+0)</font></td>
</tr>
<tr>
<td id="name">Movement Speed:</td>
<td class="border" id="color"><font color="#e81123">335</font></td>
<td id="name">Range:</td>
<td id="color"><font color="#0451ff">550</font></td>
</tr>
</table>
</center>
</div>
and the CSS for stats is as follows:
#stats {
width:480px;
height:173px;
background:#09090A;
margin-left:auto;
margin-right:auto;
border:1px solid black;
padding:3px;
padding-bottom:5px;
}
#stats table tr #name {
width:35%;
height:20px;
text-align:center;
padding-left:4px;
}
#stats table tr #color {
color:#e97900;
padding-left:2px;
padding-right:2px;
}
#stats table tr .border {
border-right:1px solid black;
}
#stats table tr td {
width:13%;
text-align:center;
line-height:245%;
font-size:14px;
background-color:#1a1a1a;
}
#stats table tr {
border-bottom:1px solid black;
}
#stats table tr:last-child {
border-bottom:0;
}
In Chrome, Safari and Firefox, the tables look like this:
which is what I want; everything across on one line nice and neat. But on Internet Explorer all of the tables look like this:
is there a way to force the table to format correctly in Internet Explorer?
with your updated css, I was able to replicate and this fixes the problem
#stats table tr td {
width:13%;
text-align:center;
line-height:245%;
font-size:14px;
background-color:#1a1a1a;
white-space:nowrap;
}
in your CSS?
I'm trying to get a table to be 100% width of a div...
But when I use width=100% it expands outside of the borders... When using on different devices...
So I'd just like this table, across full width - and the N/A button right aligned...
Seems it is always extending past borders on different devices...
<div class=flist>
<table cellpadding=2 border=1>
<tr>
<td valign=middle>
<img src="images/plus.png" height=14 width=14 border=0 align=middle> <b>General Stuff</b>
</td>
<td align=right>
<input type="button" name="CheckAll" value="All N/A" class=verd8></td>
<td> </td>
</tr>
</table>
</div>
Take this example :
<html>
<body>
<head>
<style>
.flist{
border:1px solid red;
padding:5px;
width:500px;
}
table{
width:100%;
border:1px solid;
}
</style>
</head>
<div class="flist">
<table cellpadding="2" border="1">
<tr>
<td valign=middle>
<b>General Stuff</b>
</td>
<td align=right>
<input type="button" name="CheckAll" value="All N/A" class=verd8></td>
<td> </td>
</tr>
</table>
</div>
</body>
</html>
Just an inline css example, but it works if you change .flist width the table width changes, note the red color of the .flist versus black of table.
div.flist{width:500px;}
div.flist table{width:100%;}
This should work in most cases.
if you need mobile, use media queries instead.
Adding 1% each side is = 20px so just minus that from the table width. 1% = 10px;
*{
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
table{
width: 100%;
border-spacing: 0;
border-collapse: collapse;
empty-cells:show;
}
table.bordered{
border-collapse:separate;
border:1px solid #ccc;
border-radius:4px;
}
th,td{
vertical-align:top;
padding:0.5em;
}
tr:nth-child(2n){
background-color:#f5f5f5;
}
-
<table class="bordered">
<tbody></tbody>
</table>
Just write table tag like this
<table width=100%></table>
This might have worked
Added this also into table
style="table-layout:fixed"
.flist {
font-family: Verdana; font-size: 13pt; font-weight: bold;
overflow: hidden;
position: relative;
background-color: #e9e9e9;
padding: 5px;
margin-top: 5px;
margin-left: 1%;
margin-right: 1%;
border: 1px solid #000;
}
.flist > table
{
width: 100%;
}
<div class=flist>
<table cellpadding=2 border=0 style="table-layout:fixed">
<tr>
<td valign=middle>
<b>General</b>
</td>
<td align=right>input type="button" name="CheckAll" value="All N/A" class=verd8></td>
</tr>
</table>
</div>