[HTML_CSS]HTML_CSS实战:制作一个常见的hexo样式的博客

背景

上一节个人漫威博客没有使用到div,这一节用起来~~~

示意图

在这里插入图片描述

代码

补充知识点

  • 左边固定,右边自适应

     .content{
            display: flex;
        }
        .left{
         position:fixed;
         }
        .right{
            flex-grow: 1;
            position:absolute;
        }
    
  • 引用icon,fontawesome
    先认准官网地址:这个https://fontawesome.com/
    注册后会有邮件告诉你引用的代码,copy到html,和css的引入方式差不多。
    然后搜索想要的icon,fa-2x是大小
    eg:

      <i class="fa fa-github fa-2x" aria-hidden="true"></i>
    
  • px / em / vh
    px : 像素,绝对单位
    em : 针对父元素,采用倍数,相对单位
    vh :视窗百分比

(下午coding的时候,进入了一个很相似的网站,最后引用的时候尽然收费!!!要去淘宝购买???)

基础骨架搭建

  1. 整体

    <div class="content">
    	<div class="left"></div>
    	<div class="right"><div>
    </div>
    
  2. 左边

    	<nav>
                    <section id="info">
                        <img src="images/my.jpg" alt="tina">
    
                    </section>
                    <section id="info2">
                        <h1>Tina</h1>
                        <h3>Welcome to see my blog</h3>
                        <ul class="menu">
                            <li>
                                <a href="">主页</a>
                            </li>
                            <li>
                                <a href="">技术博客</a>
                            </li>
                            <li>
                                <a href="">生活</a>
                            </li>
                            <li>
                                <a href="">关于我</a>
                            </li>
                        </ul>
                        <ul class="icon">
                            <li>
                                <a href="">
                                    <i class="fa fa-github fa-2x" aria-hidden="true"></i>
                                </a>
                            </li>
                            <li>
                                <a href="">
                                    <i class="fab fa-cuttlefish fa-2x"></i>
                                </a>
                            </li>
                            <li>
                                <a href="">
                                    <i class="fab fa-facebook fa-2x"></i>
                                </a>
                            </li>
                        </ul>
                    </section>
                </nav>
    
  3. 右边文章模板

    <div class="right">
    <div class="card">
                    <div class="article">
                        <header>
                            <span style="font-size:20px;">This is a longer card</span>
                            <span>2020-05-09</span>
                        </header>
                        <hr />
                        <article>
                            This is a longer card with supporting text below as a natural lead-in to additional content.
                            This
                            content is a little bit longer.
                            This is a longer card with supporting text below as a natural lead-in to additional content.
                            This
                            content is a little bit longer.
                            This is a longer card with supporting text below as a natural lead-in to additional content.
                            This
                            content is a little bit longer.
                            This is a longer card with supporting text below as a natural lead-in to additional content.
                            This
                            content is a little bit longer.
                            This is a longer card with supporting text below as a natural lead-in to additional content.
                            This
                            content is a little bit longer.
                            This is a longer card with supporting text below as a natural lead-in to additional content.
                            This
                            content is a little bit longer.
                        </article>
                        <hr />
                        <footer>
                            <i class="fas fa-tags"> HTML+CSS</i>
                            <a href="">More...</a>
                        </footer>
                    </div>
                </div>
               <div>
    
  4. css

    body{
        margin:0;
    }
    .content{
        display: flex;
       
    }
    .left{
       
        width: 22%;
        height:100%;
        background-color: white;
        text-align: center;
        position:fixed;
    }
    #info{
        background-color: RGB(77,77,77);
        height:180px;
    }
    #info img{
        width: 100px;
        height: 100px;
        border: 4px solid RGB(234,234,234); 
        border-radius: 50px;
        margin-top:120px;
        
    }
    #info2{
        margin-top:80px;
    }
    nav li{
        list-style-type:none;
    }
    a{
        text-decoration: none;
    }
    #info2 h1{
        color:RGB(105,105,105);
        font-size: 1.5em;
    }
    nav,li,a{
        color: RGB(153,153,153);
    }
    .menu{
      
        margin-top:3em;
    
    }
    .menu li{
        margin-top:1em;
    }
    .menu a{
        align-items:center; 
        margin-right: 2em;
        width:100%;
        margin-top:2em;
    }
    .icon{
        text-align: center;
        padding-left:6.5em;
        margin-top:2em;
    }
    .icon li{
        float:left;
        margin-right:1em;
    }
    .right{
        position:absolute;
        width: 78%;
        flex-grow: 1;
        background-color:RGB(234,234,234);
        margin-left:22%;
       
    }
    .card{
        background-color: white;
        margin:50px;
    }
    .article{
        padding:30px;
    }
    .article header{
        display: flex;
        justify-content: space-between;
    }
    
    .article article{
        margin-top:10px;
    }
    .article footer{
        display: flex;
        justify-content: space-between;
    }
    
    
    

整体html代码

```clike
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <!-- 自适应 -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 为IE服务 -->
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>hexo blog</title>
    <script src="https://kit.fontawesome.com/bdcd850d9d.js"></script>
    <link rel="stylesheet" href="css/4.css">
</head>

<body>

    <div class="content">
        <div class="left">
            <nav>
                <section id="info">
                    <img src="images/my.jpg" alt="tina">

                </section>
                <section id="info2">
                    <h1>Tina</h1>
                    <h3>Welcome to see my blog</h3>
                    <ul class="menu">
                        <li>
                            <a href="">主页</a>
                        </li>
                        <li>
                            <a href="">技术博客</a>
                        </li>
                        <li>
                            <a href="">生活</a>
                        </li>
                        <li>
                            <a href="">关于我</a>
                        </li>
                    </ul>
                    <ul class="icon">
                        <li>
                            <a href="">
                                <i class="fa fa-github fa-2x" aria-hidden="true"></i>
                            </a>
                        </li>
                        <li>
                            <a href="">
                                <i class="fab fa-cuttlefish fa-2x"></i>
                            </a>
                        </li>
                        <li>
                            <a href="">
                                <i class="fab fa-facebook fa-2x"></i>
                            </a>
                        </li>
                    </ul>
                </section>
            </nav>
        </div>
        <div class="right">
            <div class="card">
                <div class="article">
                    <header>
                        <span style="font-size:20px;">This is a longer card</span>
                        <span>2020-05-09</span>
                    </header>
                    <hr />
                    <article>
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                    </article>
                    <hr />
                    <footer>
                        <i class="fas fa-tags"> HTML+CSS</i>
                        <a href="">More...</a>
                    </footer>
                </div>
            </div>
            <div class="card">
                <div class="article">
                    <header>
                        <span style="font-size:20px;">This is a longer card</span>
                        <span>2020-05-09</span>
                    </header>
                    <hr />
                    <article>
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                    </article>
                    <hr />
                    <footer>
                        <i class="fas fa-tags"> HTML+CSS</i>
                        <a href="">More...</a>
                    </footer>
                </div>
            </div>
            <div class="card">
                <div class="article">
                    <header>
                        <span style="font-size:20px;">This is a longer card</span>
                        <span>2020-05-09</span>
                    </header>
                    <hr />
                    <article>
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                    </article>
                    <hr />
                    <footer>
                        <i class="fas fa-tags"> HTML+CSS</i>
                        <a href="">More...</a>
                    </footer>
                </div>
            </div>
            <div class="card">
                <div class="article">
                    <header>
                        <span style="font-size:20px;">This is a longer card</span>
                        <span>2020-05-09</span>
                    </header>
                    <hr />
                    <article>
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                        This is a longer card with supporting text below as a natural lead-in to additional content.
                        This
                        content is a little bit longer.
                    </article>
                    <hr />
                    <footer>
                        <i class="fas fa-tags"> HTML+CSS</i>
                        <a href="">More...</a>
                    </footer>
                </div>
            </div>
        </div>
    </div>
</body>

</html>
```

本节代码地址

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值