首页 > 解决方案 > 如何在 HTML 中进行这样的布局?

问题描述

[网页设计菜鸟] 我正在尝试创建如下布局: 在此处输入图像描述 这是我迄今为止尝试过的:

.inner,
.outer {
    position: relative;
}
.dash {
    border: 0;
    border-top: 1px dashed #cfcfcf;
}
.vertical-line {
    width: 2px;
    height: 100px;
    background: 100% #4a90e2;
    margin: 0 auto;
}
.outer {
    width: 10px;
    height: 10px;
    border: 1px solid #4a90e2;
    border-radius: 50%;
}
.inner {
    background-color: #4a90e2;
    top: 25%;
    left: 25%;
    width: 50%;
    height: 50%;
    border: 1px solid #4a90e2;
    border-radius: 50%;
}
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Opportunity</title>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.0/css/bootstrap.min.css">
    </head>
    <body>
        <div>
            <div class="container">
                <div class="row">
                    <div class="col">
                        <h1 style="font-size:15px;padding-top:34px;font-family:Lato, sans-serif;font-weight:bold;">HOW YOU CAN REACH MICHAEL</h1>
                        <hr style="max-width:60px;height:8px;max-height:8px;margin-left:1px;">
                    </div>
                    <div class="col-lg-5" style="margin-top:34px;margin-right:40px;">
                        <div class="row rounded" style="background-image: linear-gradient(-140deg, #2217A4 0%, #8326B8 100%);">
                            <div class="col" style="padding-top:5px;">
                                <h5 style="font-size:10px;color:rgb(255,255,255);font-family:Lato, sans-serif;font-weight:bold;margin-top:1px;">Reach out to Philip, for an introduction</h5>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-6 col-lg-1" style="padding-right:0px;padding-left:0px;padding-top:12px;"><img src="https://cdn.pixabay.com/photo/2018/08/28/12/41/avatar-3637425_960_720.png" class="rounded pull-right" style="min-width:50px;max-width:50px;">
                        <div class="vertical-line" style="margin-right:24px;"></div>
                        <div class="outer" style="margin-right:0px;padding-right:0px;">
                            <div class="inner" style="padding-right:-3px;"></div>
                        </div>
                    </div>
                    <div class="col" style="padding-top:12px;">
                        <h5 style="font-size:15px;margin-bottom:0px;font-family:Lato, sans-serif;font-weight:bold;">John Doe (You)</h5>
                        <h5 style="color:#797979;font-size:15px;font-family:Lato, sans-serif;">Founder at ESOP International</h5>
                        <hr class="dash" style="margin-top:45px;">
                    </div>
                    <div class="col-md-6"></div>
                </div>
                <div class="row">
                    <div class="col-md-6"></div>
                    <div class="col-md-6"></div>
                </div>
                <div class="row">
                    <div class="col-md-6"></div>
                    <div class="col-md-6"></div>
                </div>
                <div class="row">
                    <div class="col-md-6"></div>
                    <div class="col-md-6"></div>
                </div>
            </div>
        </div>
    </body>
</html>

谁能帮我

  1. col在s之间对齐垂直和水平“线”

  2. 在布局的右侧添加矩形?

标签: csshtmltwitter-bootstrapbootstrap-4

解决方案


我已经根据您的图像结构更改了布局。包括引导程序并尝试以下代码。我希望这个解决方案会有所帮助。

* {
    box-sizing: border-box;
    position: relative;
    font-family: Lato, sans-serif;
}

.combo-box h5 {
    background-image: linear-gradient(-140deg, #2217A4 0%, #8326B8 100%);
    font-size: 11px;
    color: rgb(255, 255, 255);
    font-family: Lato, sans-serif;
    font-weight: bold;
    padding: 10px 10px;
    text-align: center;
    border-radius: 3px;
}

.combo-box h3 {
    font-size: 15px;
    font-family: Lato, sans-serif;
    font-weight: bold;
    position: relative;
}

.combo-box h3::after {
    position: absolute;
    content: "";
    width: 70px;
    background-color: rgba(0, 0, 0, 0.1);
    height: 1px;
    bottom: -8px;
    left: 0;
}

.combo-box {
    padding: 0 25px;
}

.combo-box ul {
    margin: 0;
    padding: 0;
    list-style: none;
    position: relative;
}

.combo-box ul:last-child:before {}

.combo-box ul::before {
    position: absolute;
    content: "";
    background: #4b90e2;
    width: 1px;
    height: 100%;
    left: 30px;
}

.combo-box ul li {
    position: relative;
    margin: 0 0 0;
    padding: 0 0 0;
    list-style: none;
}

.combo-box .img img {
    width: 60px;
}

.combo-box .profile-desc h4 {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 0;
}

.combo-box .profile-desc small {
    color: #888;
}

.combo-box li.left {
    display: flex;
}

.combo-box ul li.right::after {
    position: absolute;
    content: "";
    width: 12px;
    height: 12px;
    border: 1px solid #4b90e2;
    border-radius: 50%;
    left: 25px;
    top: 40%;
    background: #fff;
    padding: 2px;
}

.combo-box ul li.right:before {
    border-top: 2px dashed #ccc;
    position: absolute;
    content: "";
    left: 30px;
    width: 85%;
    top: 50%;
}

.combo-box .inner-desc {
    display: flex;
}

.combo-box ul li.right .inner-desc:before {
    position: absolute;
    content: "";
    left: 28px;
    background: #4b90e2;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    top: 47%;
    z-index: 9;
}

.combo-box ul li.right {
    text-align: right;
}

.combo-box ul li.right p {
    margin-left: auto;
    text-align: right;
    font-size: 12px;
    display: inline-block;
    background: #f8f8f8;
    border: 1px solid #e6e6e6;
    padding: 5px 8px;
    margin-bottom: 0;
    line-height: 18px;
    border-radius: 3px;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container my-5">
    <div class="combo-box">
        <div class="row">
            <div class="col-md-7">
                <h3>HOW YOU CAN REACH MICHAEL</h3>
            </div>
            <div class="col-md-5">
                <h5>Reach out to Philip, for an introduction</h5>
            </div>
        </div>

        <ul>
            <li class="left">
                <div class="img mr-3">
                    <img src="https://cdn.pixabay.com/photo/2018/08/28/12/41/avatar-3637425_960_720.png" class="img-fluid">
                </div>
                <div class="profile-desc">
                    <h4>John Doe (You)</h4>
                    <small>Founder at ESOP International</small>
                </div>
            </li>
            <li class="right">
                <div class="inner-desc">
                    <p>Lorem Ipsum is simply dummy text of
                        <br>typesetting industry. </p>
                </div>
            </li>
        </ul>

        <ul>
            <li class="left">
                <div class="img mr-3">
                    <img src="https://cdn.pixabay.com/photo/2018/08/28/12/41/avatar-3637425_960_720.png" class="img-fluid">
                </div>
                <div class="profile-desc">
                    <h4>John Doe (You)</h4>
                    <small>Founder at ESOP International</small>
                </div>
            </li>
            <li class="right">
                <div class="inner-desc">
                    <p>Lorem Ipsum is simply dummy text of
                        <br>typesetting industry. </p>
                </div>
            </li>
        </ul>

        <ul>
            <li class="left">
                <div class="img mr-3">
                    <img src="https://cdn.pixabay.com/photo/2018/08/28/12/41/avatar-3637425_960_720.png" class="img-fluid">
                </div>
                <div class="profile-desc">
                    <h4>John Doe (You)</h4>
                    <small>Founder at ESOP International</small>
                </div>
            </li>
            <li class="right">
                <div class="inner-desc">
                    <p>Lorem Ipsum is simply dummy text of
                        <br>typesetting industry. </p>
                </div>
            </li>
        </ul>

        <ul>
            <li class="left">
                <div class="img mr-3">
                    <img src="https://cdn.pixabay.com/photo/2018/08/28/12/41/avatar-3637425_960_720.png" class="img-fluid">
                </div>
                <div class="profile-desc">
                    <h4>John Doe (You)</h4>
                    <small>Founder at ESOP International</small>
                </div>
            </li>
        </ul>
    </div>
</div>


推荐阅读