我正在尝试使用css样式加载图像,并且我周围有一个红色的脊边框,但出于某种原因,当我使用css而不是html时,我在红色脊边框内部得到一个奇怪的小白边框左上角有一个白色标志,小标识可能是一个小小的显示器,我不知道怎么形容它。有谁知道发生了什么?我有其他图像以相同的方式加载没有问题。
这是CSS脚本
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;
}
答案 0 :(得分:2)
这是你的意思:
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;
}
查看小提琴:Fiddle
必须在px
修改强>
将您的img
标记移至div
中
<div id="logo"><img/></div>
然后添加其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;
}
以下是工作小提琴:Fiddle
答案 1 :(得分:1)
你的HTML是问题所在。你有没有指定来源的图像,但你改为背景。浏览器正在尝试读取图像但无法找到源。例如,使用图像源并删除背景或使用范围并留下背景。