我想在我的主页左侧放一张图片。我知道如何在 html 中执行此操作,但我想在 CSS 类中创建它。我不知道我需要做什么来修复它。我要的图片叫Nobullying.jpg HTML:
<html>
<head>
<link rel="stylesheet" type="text/css" href="body.css"/>
</head>
<body>
<h1>Bully-Free Zone</h1>
<h2>"Online harassment has an off-line impact"</h2>
<!--Menu-->I
<div id="nav">
<a href="mainpage.htm" class="nav-link">HOME</a>
<a href="page1.htm" class="nav-link">ASSISTANCE</a>
<a href="page2.htm" class="nav-link">CYBER-BULLYING SIGNS</a>
<a href="page3.htm" class="nav-link">REPORT</a>
</div>
<div id="picture"></div>
<!--Copyright-->
<div id="center">
<td> Copyright © 2012 Bully-FreeZone.com</td>
</div>
</body>
</html>
CSS类:
#picture{background-image:Nobullying.jpg;
width:40px; height:40px;
}
这是我要图片的地方。 (红框) http://imgur.com/Ef2Au
最佳答案
#picture {
background-image:url('no-bullying.jpg');
height:100px;
width:50px;
position: absolute;
bottom:10px;
left:10px;
}
关于html - 如何在CSS上对齐图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10193696/