小图标应该怎样加 绝对定位脱离文档流

来源:6-6 作业题

慕后端8593059

2018-11-08 10:18:27

<!DOCTYPE html>
<html>
<head>
 <meta charset="UTF-8">
 <title>项目作业</title>
 <link rel="stylesheet" type="text/css" href="js/index.css">
</head>
<body>
 <div class="top">
  <div class="wrap">
   <div class="top-1">
    <img src="img/icon-call.png">
    <span>010-114/116114电话预约</span>
   </div>
   <div class="top-2">
    <span>欢迎来到城市预约挂号统一平台&nbsp;请&nbsp;&nbsp;
     <a href="#">登录</a>&nbsp;&nbsp;
     <a href="#">注册</a>&nbsp;&nbsp;&nbsp;&nbsp;
     <a href="#">帮助中心</a>
    </span>
   </div>
  </div>
 </div>
 <div class="header">
  <div class="header-1">
   <img src="img/logo.png">
   <div class="header-2 ui-header">
    <div class="ui-header-selected">医院</div>
    <div class="ui-header-select-list">
     <a href="#1">科室</a>
     <a href="#1">疾病</a>
     <a href="#1">医院</a>
    </div>
    <input type="text" name="header-content" class="ui-search-input" placeholder="请输入搜索内容">
    <a href="#" class="ui-header-submit">&nbsp;</a>
   </div>
  </div>
 </div>
 <div class="nav">
  <div class="nav-1">
   <a href="#" class="left">首页</a>
   <a href="#" class="left">按医院挂号</a>
   <a href="#" class="left">按科室挂号</a>
   <a href="#" class="left">按疾病挂号</a>
   <a href="#" class="left">最新公告</a>
   <a href="#" class="right">社会知名医院</a>
  </div>
 </div>
 <!-- 简介intro -->
 <div class="content">
  <div class="content-1">
   <div class="content-2">
    <span class="a">北京协和医院</span>&nbsp;
    <span class="b">关注医院</span>
    <span class="c">
     <a href="#">等级:</a>三级甲等&nbsp;&nbsp;
     <a href="#">区域:</a>东城区&nbsp;&nbsp;
     <a href="#">分类:</a>中国医科院附属医院
    </span>
   </div>
   <div class="content-3">
    <div class="content-left">
     <img src="img/hospital-1.jpg">
    </div>
    <div class="center">
     <p class="icon">[东院]北京市东城区帅府园一号[西院]北京市西城区大木仓胡同41号</p>
     <p class="icon">http//:www.pumch.cn/</p>
     <p class="icon">东院咨询台:010-692124124;西院咨询台:010-315351616</p>
     <p class="icon">东院:106,108,110,111,116,684,685到东单路口北41,104快814到东城区南门口;1,52,728,802到东单路口西;20,25,37,39,到东单路口东;<br/>
     103,130,314,124到新东安市场;地铁1,5号线到东单。西院:68到辟才胡同东口;更多乘车路线详见须知</p>
    </div>
    <div class="content-right">
     <img src="img/map-1.png">
    </div>
   </div>
  </div>
 </div>
</body>
</html>



*{
 padding: 0;
 margin:0;
}
a{
 text-decoration: none;
 color: blue;
}
.top{
 background: #f5f5f5;
 height: 40px;
}
.wrap{
 width: 1000px;
 margin: 0 auto;
}
.top-1{
 float: left;
 line-height: 40px;
}
.top-2{
 float: right;
 line-height: 40px;
}
.header{
 width: 1000px;
 
 margin:0 auto;
 position: relative;
}
.header-1{
 width: 400px;
 height: 75px;
}
.header-1 img{
 width: 100%;
 height: 100%;
}
.header-2{
 width: 326px;
 height: 40px;
 position: absolute;
 top:20px;
 right: 0;
 background: url(../img/ui-search.jpg) center no-repeat;
}
.ui-header-selected{
 width:78px;
 height: 38px;
 line-height: 38px;
 position: absolute;
 left: 0;
 top: 0;
 text-indent: 14px;/*首行缩进*/
}
.ui-header-select-list{
 display: none;
 position: absolute;
 width: 67px;
 line-height: 24px;
 background-color: #f5f5f5;
 left: 2px;
 top: 36px;
 z-index: 2;
}
.ui-header-select-list a{
 display: block;
 text-align: center;
 color:#A5a2a2;
}
.ui-search-input{
 width:212px;
 height: 32px;
 position: absolute;
 left:69px;
 top:2px;
}
.nav{
 background:#60bff2;
}
.nav-1{
 width:1000px;
 height:40px;
 line-height: 40px;
 margin:0 auto;
}
.nav-1 a{
 color: #fff;
}
.left{
 padding-left: 50px;
}
.right{
 float: right;
}
.content{
 height: 60px;
 margin-top: 20px;
}
.content-1{
 width:1000px;
 margin:0 auto;
 background: #f7f7f7;
}
.content-2 {
    line-height: 60px;
    border-bottom: 1px solid #ccc;
    margin: 0 20px;
}
.content-2 .a{
 font-size: 20px;
}
.content-2 .b{
 font-size: 15px;
 color: orange;
}
.content-2 .c{
 float: right;
}
.content-3{
 width: 1000px;
 height: auto;
 margin:0 auto;
    overflow: hidden;
}
.content-left{
 width: 200px;
 margin-right: 30px;
 margin: 15px 20px;
 float: left;
}
.content-left img{
 width: 100%;
}
.center{
 width: 440px;
 height: 210px;
 float: left;
 margin-top: 15px;
 margin-left: 50px;
 font-size: 10px;
 line-height: 30px;
}
.content-right{
 float: right;
 margin-top: 15px;
 margin-right: 20px;
}
.content-right img{
 width: 100%;
 height: 180px;
}

写回答

1回答

好帮手慕夭夭

2018-11-08

同学你好 ,是说的如下图标吗 ?

http://img.mukewang.com/climg/5be3a4cb0001e8ac04900226.jpg

可以给每个icon元素的伪类设置背景图标 , 例如第一个图标 , 如下:

添加一个单独的类名

http://img.mukewang.com/climg/5be3a5d2000145bb07400090.jpg

样式:

icon设置相对定位 ,是图标参照其定位 ,然后在伪类中设置图标 

http://img.mukewang.com/climg/5be3a623000144ce06020351.jpg

希望能够帮到你 , 祝学习愉快 望采纳


0

0 学习 · 36712 问题

查看课程