老师您好我有个问题请教

来源:4-7 小慕医生项目开发(5)

ZcKing

2020-12-14 21:22:26

# 具体遇到的问题
按照课程视频要求书写代码,我发现<a></a>的高度应该被撑开(内部的img和转块的span是有高度的),但是实际情况下却没有,这里不是很理解。
# 报错信息的截图
http://img.mukewang.com/climg/5fd7663e092d3a0614070781.jpg# 相关课程内容截图

# 尝试过的解决思路和结果

# 粘贴全部相关代码,切记添加代码注释(请勿截图)

* {

    padding0;

    margin0;

}


/* 去掉所有ul ol的小圆点 */

ulol {

    list-stylenone;

}


/* 去掉所有超级链接下划线 */

a {

    text-decorationnone;

}


/* 使用继承性,给body标签设置字体 */

body {

    fontnormal 14px/25px '微软雅黑';

}


/* 页面头部样式 */

header {


}


/* 页面头部上半部分 */

header .header-top {

    width1201px;

    margin0 auto;

    /* 清除浮动 */

    overflowhidden;

}


header .header-top .logo {

    padding-top39px;

    width193px;

    height63px;

    /* 左浮动 */

    floatleft;

    color#015E58;

    font-size20px;

}


header .header-top .logo h1 {

    width193px;

    height63px;

}


header .header-top .tool {

    /* 右浮动 */

    floatright;

    width266px;

    height65px;

    padding36px;

}


header .header-top .tool .row1 {

    margin-bottom12px;

}


header .header-top .tool .row1 .tel {

    width32px;

    height26px;

}


header .header-top .tool .row1 .telnumber {

    font-size20px;

    color#00978E;

    displayinline-block;

    width158px;

    height26px;

    text-aligncenter;

}


header .header-top .tool .row1 .icon {

    width24px;

    height24px;

}


header .header-top .tool .row1 .chinese_icon {

    margin-right7px;

}


header .header-top .tool .row2 {

    width264px;

    height28px;

    border1px solid rgba(202,202,202,0.60);

    background#FFFFFF;

}


header .header-top .tool .row2 input {

    floatleft;

    width224px;

    height28px;

    bordernone;

    padding-left20px;

    outlinenone;

}


header .header-top .tool .row2 button {

    floatleft;

    bordernone;

    width20px;

    height20px;

    backgroundnone;

    outlinenone;

    cursorpointer;

    /* 相对定位微调位置 */

    positionrelative;

    top3px;

    right3px;

}


/* 导航条样式设计 */

header .main-nav {

    width100%;

    height60px;

    background-color#00978E;

    margin0 auto;

}


header .main-nav ul {

    height60px;

    padding-left360px;

}


header .main-nav ul li {

    floatleft;

    width150px;

    height60px;

    font-size16px;

    color#FFFFFF;

    /* 行高设置文字垂直居中 */

    line-height60px;

    text-aligncenter;

}


header .main-nav ul li.current {

    background-color#015E58;

}


header .main-nav ul li a {

    displayblock;

    width150px;

    height60px;

    font-size16px;

    color:white;

}


header .main-nav ul li a:hover {

    background-colororange;

}


.banner {

    width100%;

    positionrelative;

}


.banner .banner-img {

    width100%;

    displayblock;

}


.banner .center {

    width1200px;

    height300px;

    /* background-color: orange; */

    /* 绝对定位 */

    positionabsolute;

    top50%;

    left50%;

    margin-top-150px;

    margin-left-600px;

}


.banner .center h2 {

    font-size60px;

    font-weightnormal;

    color#015E58;

    /* 绝对定位 */

    positionabsolute;

    top50%;

    margin-top-84px;

    margin-left148px;

}



.banner .center .left-btn {

    displayinline-block;

    width56px;

    height64px;

    background-colorrgba(202,202,202,0.60);

    line-height64px;

    text-aligncenter;

    /* 利用绝对定位垂直居中 */

    positionabsolute;

    top50%;

    left0;

    margin-top-32px;

}


.banner .center .right-btn {

    displayinline-block;

    width56px;

    height64px;

    background-colorrgba(202,202,202,0.60);

    line-height64px;

    text-aligncenter;

    /* 利用绝对定位垂直居中 */

    positionabsolute;

    top50%;

    right0;

    margin-top-32px;

}


.banner ol {

    width120px;

    height12px;

    /* background-color: red; */

    /* 绝对定位 */

    positionabsolute;

    left50%;

    margin-left-60px;

    bottom20px;

}


.banner ol li {

    width20px;

    height12px;

    floatleft;

    background-colorwhite;

    margin-right10px;

    /* 设置圆角 */

    border-radius10px;

}


.banner ol li:last-child {

    margin-right0px;

}


.banner ol li.current {

    width30px;

    background-colororange;

}


/* 内容部分 */

.content {

    padding-top71px;

}


.content .useful-links {

    width906px;

    height151px;

    background-colororange;

    margin0 auto;

}


.content .useful-links ul {

    /* 清除浮动 */

    overflowhidden;

}


.content .useful-links ul li {

    floatleft;

    width104px;

    margin-right54px;

}


.content .useful-links ul li:last-child {

    margin-right0;

}


.content .useful-links ul li span {

    /* 转块,不设置宽度,就相当于width属性为100% */

    displayblock;

    text-aligncenter;

    color#333333;

    font-size20px;

    line-height40px;

}


<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>张氏医院</title>

    <meta name="Keywords" content="张氏医院是专业的医院,理念就是责任、品质、关爱">

    <meta name="Description" content="美容、减脂、内科、外科">

    <link rel="stylesheet" href="css/css.css">

</head>

<body>

    <!-- 页面头部 -->

    <header>

        <!-- 页面头部上半部分 -->

        <div class="header-top">

            <!-- 网页logo -->

            <div class="logo">

                <h1>张氏医院</h1>

            </div>

            <!-- 功能区域 -->

            <div class="tool">

                <div class="row1">

                    <img class="tel" src="images/tel.png" alt="咨询电话" />

                    <span class="telnumber">400-888888888</span>

                    <img class="chinese_icon icon" src="images/chinese_icon.png" alt="切换中文" />

                    <img class="english_icon icon" src="images/english_icon.png" alt="切换英文" />

                </div>

                <div class="row2">

                    <input placeholder="找医生/找科室...">

                    <button><img src="./images/search.png" /></button>

                </div>

            </div>

        </div>

        <!-- 网页导航条 -->

        <nav class="main-nav">

            <ul>

                <li class="current"><a href="#">页首</a></li>  

                <li><a href="#">医院概况</a></li>

                <li><a href="#">医院动态</a></li>

                <li><a href="#">专家学科</a></li>

                <li><a href="#">服务指南</a></li>

                <li><a href="#">医院文化</a></li>

                <li><a href="#">信息公开</a></li>

                <li><a href="#">互动交流</a></li>

            </ul>

        </nav>

    </header>


    <!-- 网页banner -->

    <section class="banner">

        <img class="banner-img" src="images/banner.png" />

        <div class="center">

            <h2>责任、科学、严谨</h2>

            <a class="left-btn" href="#">&lt;</a>

            <a class="right-btn" href="#">&gt;</a>

        </div>

        <!-- 手动轮播图——小圆点 -->

        <ol>

            <li class="current"></li>

            <li></li>

            <li></li>

            <li></li>

        </ol>

    </section>


    <!-- 网页的主要内容 -->

    <section class="content">

        <!-- 常用链接 -->

        <div class="useful-links">

            <ul>

                <li>

                    <a href="#">

                        <img src="images/icon_jzxz.png" />

                        <span>就诊须知</span>

                    </a>

                </li>

                <li>

                    <a href="#">

                        <img src="images/icon_jylc.png" />

                        <span>就医流程</span>

                    </a>

                </li>

                <li>

                    <a href="#">

                        <img src="images/icon_zjjs.png" />

                        <span>专家介绍</span></a>

                </li>

                <li>

                    <a href="#">

                        <img src="images/icon_ksjs.png" />

                        <span>科室介绍</span></a>

                </li>

                <li>

                    <a href="#">

                        <img src="images/icon_ybjy.png" />

                        <span>医保就医</span></a>

                </li>

                <li>

                    <a href="#">

                        <img src="images/icon_jktj.png" />

                        <span>健康体检</span>

                    </a>

                </li>

            </ul>

        </div>

        .... 后续代码无关

写回答

1回答

好帮手慕张

2020-12-15

同学你好,a标签是行内元素,不能被嵌套的子元素撑起高度,如果想要撑起高度,可以给a标签通过display:block;转块元素即可。

祝学习愉快!


1
hcKing
hp>谢谢老师解惑

h020-12-15
共1条回复

0 学习 · 15276 问题

查看课程