有没有办法在相同的div元素中放置边框botton

时间:2019-02-19 14:20:21

标签: html css

除了将border-bottom的div元素放在主div之外,还有一种方法将border-bottom-bottom放在主div元素之内。这是我想发生的https://i.imgur.com/jmAkBP7.png屏幕截图,当您注意到有一条蓝线时,它是边框的底部。

html,
body {
    margin: 0;
    padding: 0;
}
.wrap {
    height: 100vh;
    display: grid;
    grid-gap: 3px;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: 100px auto 100px;
}

.headNav {
    position: relative;
    grid-column: 1 / -1;
    overflow: hidden;
    /* background: #000; */
}


.menu {
    grid-column: 1 / 3;
    grid-row: auto;
    /* background: pink; */
}

.content {
    grid-column: 3 / -1;
    /* background-color: blue; */
}

.footer {
    grid-column: 1 / -1;
    /* background: #000; */
}

.body {
    background-image: linear-gradient( 
                    rgba(0, 31, 63, 0.958), 
                    rgba(0, 31, 63, 0.958) ) 
                    ,url(./img/bgmain.jpg);
    background-size: cover;
}

.logo {
    display: inline;
}

.logo > img  {
    display: inline;
    padding-top: 10px;
    height:80px;
    padding-left: 20px;
}

.link, ul, li {
    display: inline;
    list-style-type: none;
}

.link {
    position: absolute;
    top: 45px;
    left: 32.2%;
}

 li a {
    font-family: 'Raleway', sans-serif;
    font-weight: 900;
    text-transform: uppercase;
    text-decoration: none;
    font-size: 20px;
    color: #fff;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Jury Gregorio - Homepage</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="main.css">
    <link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
</head>
<body>
    <div class="wrap body">
        <div class="headNav">
            <div class="logo"><img src="./img/logo.png" alt="Logo"></div>
            <div class="link">
                <ul><li><a href="">Home</a></li></ul>
                <ul><li><a href="">About</a></li></ul>
                <ul><li><a href="">Blog</a></li></ul>
                <ul><li><a href="">Contact</a></li></ul>
            </div>
        </div>
        <div class="menu"></div>
        <div class="content"></div>
        <div class="footer"></div>
    </div>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

赞:

html,
body {
    margin: 0;
    padding: 0;
}
.wrap {
    height: 100vh;
    display: grid;
    grid-gap: 3px;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: 100px auto 100px;
}

.headNav {
    position: relative;
    grid-column: 1 / -1;
    overflow: hidden;
    /* background: #000; */
}


.menu {
    grid-column: 1 / 3;
    grid-row: auto;
    /* background: pink; */
}

.content {
    grid-column: 3 / -1;
    /* background-color: blue; */
}

.footer {
    grid-column: 1 / -1;
    /* background: #000; */
}

.body {
    background-image: linear-gradient( 
                    rgba(0, 31, 63, 0.958), 
                    rgba(0, 31, 63, 0.958) ) 
                    ,url(./img/bgmain.jpg);
    background-size: cover;
}

.logo {
    display: inline;
}

.logo > img  {
    display: inline;
    padding-top: 10px;
    height:80px;
    padding-left: 20px;
}

.link, ul, li {
    display: inline;
    list-style-type: none;
}

.link {
    position: absolute;
    top: 45px;
    left: 32.2%;
}

 li a {
    font-family: 'Raleway', sans-serif;
    font-weight: 900;
    text-transform: uppercase;
    text-decoration: none;
    font-size: 20px;
    color: #fff;
}

ul {
  border-bottom: 2px solid blue;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Jury Gregorio - Homepage</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="main.css">
    <link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet">
</head>
<body>
    <div class="wrap body">
        <div class="headNav">
            <div class="logo"><img src="./img/logo.png" alt="Logo"></div>
            <div class="link">
                <ul>
                <li><a href="">Home</a></li>
                <li><a href="">About</a></li>
                <li><a href="">Blog</a></li>
                <li><a href="">Contact</a></li>
                </ul>
            </div>
        </div>
        <div class="menu"></div>
        <div class="content"></div>
        <div class="footer"></div>
    </div>
</body>
</html>