html中div布局及其图片插入链接

 时间:2026-02-14 15:19:32

1、打开软件,新建html文件,如图,分析图片的构成部分,是由五张图片,五行字组成。建立五个div布局,每个div包含一张图片一段字。字和图片都有超链接

html中div布局及其图片插入链接

2、建立一个div包含五张图片,设置属性margin :0 auto;上下边界为0,左右相等。建立div5个,放置图片和字。

*{padding: 0;margin: 0;}

.news{width: 1080px;height: 200px;margin: 0 auto;}

html中div布局及其图片插入链接

3、.left_1{width: 200px;height: 150px;float: left;padding: 10px;}

.left_2{width: 200px;height: 150px;float: left;margin-top: 10px;}

.center{width: 200px;height: 150px;float: left;padding: 10px;}

.right_1{width: 200px;height: 150px;float: left;margin-top: 10px;}

.right_2{width: 200px;height: 150px;float: left;padding: 10px;}

html中div布局及其图片插入链接

4、给图片添加超链接

<div class="left_1">

<a href="http://news.baidu.com/" target="_blank"><img src="../img/a.jpg"height="150

   <a href="baidu.com" target="_blank">图片链接</a>

</div>

<div class="left_2">

<a href="http://news.baidu.com/" target="_blank"><img src="../img/a1.jpg"height="150

    <a href="baidu.com" target="_blank">图片链接</a>

</div>

<div class="center">

<a href="http://news.baidu.com/" target="_blank"><img src="../img/a3.jpg"height="150

    <a href="baidu.com" target="_blank">图片链接</a>

</div>

<div class="right_1">

<a href="http://news.baidu.com/" target="_blank"><img src="../img/day02.jpg"height="150

    <a href="baidu.com" target="_blank">图片链接</a>

</div>

<div class="right_2">

<a href="http://news.baidu.com/" target="_blank"><img src="../img/qiu.gif"height="150

    <a href="baidu.com" target="_blank">图片链接</a>

</div>

html中div布局及其图片插入链接

5、图片和字都加超链接。运行看一下效果。

html中div布局及其图片插入链接

6、<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8" />

<title></title>

<style>

*{padding: 0;margin: 0;}

.news{width: 1080px;height: 200px;margin: 0 auto;}

.left_1{width: 200px;height: 150px;float: left;padding: 10px;}

.left_2{width: 200px;height: 150px;float: left;margin-top: 10px;}

.center{width: 200px;height: 150px;float: left;padding: 10px;}

.right_1{width: 200px;height: 150px;float: left;margin-top: 10px;}

.right_2{width: 200px;height: 150px;float: left;padding: 10px;}

a{ display: block; text-align: center;}

a:hover{color:#00FF00;text-decoration: underline;}

</style>

</head>

<body>

<div class="news">

<div class="left_1">

<a href="http://news.baidu.com/" target="_blank"><img src="../img/a.jpg"height="150

   <a href="baidu.com" target="_blank">图片链接</a>

</div>

<div class="left_2">

<a href="http://news.baidu.com/" target="_blank"><img src="../img/a1.jpg"height="150

    <a href="baidu.com" target="_blank">图片链接</a>

</div>

<div class="center">

<a href="http://news.baidu.com/" target="_blank"><img src="../img/a3.jpg"height="150

    <a href="baidu.com" target="_blank">图片链接</a>

</div>

<div class="right_1">

<a href="http://news.baidu.com/" target="_blank"><img src="../img/day02.jpg"height="150

    <a href="baidu.com" target="_blank">图片链接</a>

</div>

<div class="right_2">

<a href="http://news.baidu.com/" target="_blank"><img src="../img/qiu.gif"height="150

    <a href="baidu.com" target="_blank">图片链接</a>

</div>

</div>

</body>

</html>

所有代码,细节自行添加

  • html字体样式怎么设置
  • html文本区域大小怎么设置
  • html图片如何居中
  • html如何把两个网页连接起来
  • html添加图片的代码
  • 热门搜索
    年报怎么做 蜂蜜祛斑方法 怎么治黑眼圈 炒面的家常做法 糯米粉可以做什么好吃的 初中生瘦腿方法 干香菇怎么泡 例假量少怎么调理 附睾炎的治疗方法 周公解梦破解大全查询