简体   繁体   English

html文档中单个图像周围的白色边框

[英]White border around single image in html document

I have a quick question, I'm making a simple html document, with an image that I want to fill the entire page. 我有一个快速的问题,我正在制作一个简单的html文档,其中包含一张我想填充整个页面的图像。

For some reason, it wants to create a border around the image. 由于某种原因,它想在图像周围创建边框。 I've tried border="0"; 我试过border =“ 0”; and padding 0px 0px 0px 0px; 和填充0px 0px 0px 0px;

Here is the code in which I have: (You can also check it out live if you prefer www.kidbomb.com/chefwannabe) 这是我所拥有的代码:(如果您喜欢www.kidbomb.com/chefwannabe,也可以实时检查它)

<!DOCTYPE html>
<html>
<head>
<title>Pre-Order Now!</title>
</head>
<body>

<img style="width: 100%; overflow:hidden;" src="http://www.kidbomb.com/chefwannabe/chefwannabepreview.png" />
</body>
</html>

Add the following CSS in your code. 在代码中添加以下CSS。 Default body will give some margin and padding. 默认主体将提供一些边距和填充。 So better whenever you start new work, add this style in your css for getting the proper result. 因此,每当您开始新工作时都会更好,请在CSS中添加此样式以获得正确的结果。

body
{
 padding:0;
 margin:0;
}  

Instead of using the img tag, set the background-image property of the body tag so it encompasses the entirety of the page. 代替使用img标签,而是设置body标签的background-image属性,使其涵盖整个页面。

body { 
    background-image: url("path/to/image.jpg");    
    height: 100%;
    width: 100%;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM