qzmjef 发表于 2024-7-27 22:32:58

学会用HTML-flex布局制作美丽的网页


    <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">1、</span>摘 要</h1>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/f84abf13fb9f4a7cb74645f18a31ea9b~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722664155&amp;x-signature=VeWHK0lmpv9KOYJbCLdiuFC2pyM%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">(OF作品展示)</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">OF之前介绍了用python实现数据可视化、数据分析及<span style="color: black;">有些</span>小项目,但基本都是后端的知识。想要做一个好看的小系统,<span style="color: black;">咱们</span>还要学<span style="color: black;">有些</span>前端的知识,今天OF将讲解<span style="color: black;">怎样</span>用pycharm(全栈<span style="color: black;">研发</span>不错的工具)做一张好看的网页,以后<span style="color: black;">咱们</span>就<span style="color: black;">能够</span>自己<span style="color: black;">研发</span>网页/网站放到互联网上。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;"><span style="color: black;">重点</span>内容:网页前端布局</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">适用人群:Python初学者,前端初学者</span></strong></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><strong style="color: blue;"><span style="color: black;">准备软件:pycharm</span></strong></p>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">2、</span>pycharm操作说明</h1>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">1. 创建项目</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">1) 下载完成pycharm, 点击file-New Project...</span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/9b06194a76aa428aac9a58f5c3175b43~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722664155&amp;x-signature=gvSFqgQPbBA%2F7wykSuDlk%2B3Tlls%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">2) 按下图<span style="color: black;">过程</span>创建一个项目,<span style="color: black;">日前</span><span style="color: black;">咱们</span><span style="color: black;">选取</span>Pure python<span style="color: black;">就可</span>,以后<span style="color: black;">咱们</span><span style="color: black;">能够</span>学习用Django/flask等框架来做完整的系统</span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/53c5a4762359479fa4bb78f219388e3e~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722664155&amp;x-signature=6kPwl1rc9WQixdgASQqB0rSRi%2B8%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">2. 创建HTML文件</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">1)在创建的项目空白处鼠标右键-New-HTML File</span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p26-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/f3797246682547f9a68100b92a61990d~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722664155&amp;x-signature=ofbAc35qwS86Jw5rKcNso4eBWU8%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">2)输入英文的网页名字,<span style="color: black;">尽可能</span>不要输入中文/特殊字符</span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/82f9a5065b8c46c4b11cf333ed26382e~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722664155&amp;x-signature=AjF741gmkmEnwUBS8o1BW8ZHIms%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">3. HTML格式说明</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">当双击打开<span style="color: black;">咱们</span>创建后的HTML文件,<span style="color: black;">大众</span>会看到下面的界面</span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/8f31891395a74ea68940608dba8d5499~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722664155&amp;x-signature=3ZFOGstfoHPD3ao0IDqtabhNrts%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">3、</span>网页设计</h1>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">1. 草图绘制</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">在<span style="color: black;">起始</span><span style="color: black;">研发</span>网页前,<span style="color: black;">咱们</span>需要自己设计下想要把网页做成什么样,为了节省成本OF都是自己设计的页面样式,<span style="color: black;">能够</span>手绘,<span style="color: black;">亦</span><span style="color: black;">能够</span>在PPT上画。</span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/3f57a1bf571a426c9f86b698be9ca07c~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722664155&amp;x-signature=hcauVFqu6ySVBO5mQBQX2eZKYGA%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/ad8b81699cd04813ac291f1e325df320~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722664155&amp;x-signature=UU8C%2FD6NFaY04X454htNnWRb%2F5I%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">2. css名字定义</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">咱们</span>先学习一个比较简单的布局如下图,<span style="color: black;">大众</span><span style="color: black;">能够</span>看到下图<span style="color: black;">已然</span>画出了<span style="color: black;">咱们</span>需要添加的内容,要<span style="color: black;">重视</span>的<span style="color: black;">地区</span>是<span style="color: black;">例如</span>Taylor的<span style="color: black;">照片</span>和文字<span style="color: black;">必定</span>要用&lt;div class=bord&gt;框住,否则Taylor<span style="color: black;">照片</span>与文字将会是<span style="color: black;">上下</span>的关系,而不是上下</span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/92cde81aa47d46c99858633f1eee8e98~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722664155&amp;x-signature=Cw2sV4ImVwvvEy1PPllT1oYKVdo%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">4、</span>网页<span style="color: black;">研发</span></h1>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">1. body部分</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">按照</span><span style="color: black;">以上</span>的css名字定义,先填充&lt;body&gt;内的代码,<span style="color: black;">那样</span><span style="color: black;">咱们</span>就完成一半的工作了,代码如下:</span></p><span style="color: black;">&lt;!DOCTYPE <span style="color: black;">html</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">html</span> <span style="color: black;">lang</span>=<span style="color: black;">"en"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">head</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">meta</span> <span style="color: black;">charset</span>=<span style="color: black;">"UTF-8"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">title</span>&gt;</span>Title<span style="color: black;">&lt;/<span style="color: black;">title</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">head</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">body</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">div</span> <span style="color: black;">id</span>=<span style="color: black;">"intro"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">p</span> <span style="color: black;">class</span>=<span style="color: black;">"peo"</span>&gt;</span><span style="color: black;">名人</span>介绍<span style="color: black;">&lt;/<span style="color: black;">p</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">div</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">div</span> <span style="color: black;">id</span>=<span style="color: black;">"pic1"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">div</span> <span style="color: black;">class</span>=<span style="color: black;">"bord"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">img</span> <span style="color: black;">class</span>=<span style="color: black;">"img"</span> <span style="color: black;">src</span>=<span style="color: black;">"pic/Taylor.png"</span>/&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">p</span> <span style="color: black;">class</span>=<span style="color: black;">"word"</span>&gt;</span>Taylor<span style="color: black;">&lt;/<span style="color: black;">p</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">div</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">div</span> <span style="color: black;">class</span>=<span style="color: black;">"bord"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">img</span> <span style="color: black;">class</span>=<span style="color: black;">"img"</span> <span style="color: black;">src</span>=<span style="color: black;">"pic/yan.png"</span>/&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">p</span> <span style="color: black;">class</span>=<span style="color: black;">"word"</span>&gt;</span>东<span style="color: black;">&lt;/<span style="color: black;">p</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">div</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">div</span> <span style="color: black;">class</span>=<span style="color: black;">"bord"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">img</span> <span style="color: black;">class</span>=<span style="color: black;">"img"</span> <span style="color: black;">src</span>=<span style="color: black;">"pic/song.png"</span>/&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">p</span> <span style="color: black;">class</span>=<span style="color: black;">"word"</span>&gt;</span>乔<span style="color: black;">&lt;/<span style="color: black;">p</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">div</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">div</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">body</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">html</span>&gt;</span>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">2. 网页测试</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">1)鼠标移到代码处,在右上角<span style="color: black;">咱们</span>会看到一排浏览器,<span style="color: black;">咱们</span>点击其中一个运行</span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/645eee55fe1f4d5cb814596143f3d507~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722664155&amp;x-signature=jmMR65MDLydty%2BkLFEkRGa5m6dk%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">2)<span style="color: black;">日前</span>看到的网页内容从上到下<span style="color: black;">表示</span></span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/16bdef5b183e4d298a8b36029ac23918~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722664155&amp;x-signature=fyQCoGXbtmQEURj%2BQNG0b8VL5BU%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">3. head部分</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">首要</span><span style="color: black;">咱们</span>简要<span style="color: black;">认识</span>下flex布局,<span style="color: black;">大众</span><span style="color: black;">能够</span>看到下图中#main的style样式中display:flex,在body部分将3个颜色内容框在&lt;div id="main"&gt;中,运行结果是3个颜色的内容横向展示了,而不是上下</span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/289f46cd92424a38a0a032b7bb81af78~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722664155&amp;x-signature=T0LrRMawYXP2GEJ7%2BVcR3AbMp1E%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">1)<span style="color: black;">那样</span><span style="color: black;">咱们</span>先从“<span style="color: black;">名人</span>介绍”的布局<span style="color: black;">起始</span>,“<span style="color: black;">名人</span>介绍”居中展现(用flex中justify-content:center),<span style="color: black;">况且</span>下面有一条黑线,OF准备用border样式来实现,<span style="color: black;">因此</span>在&lt;div id=intro&gt;里另加了个&lt;div class=peo&gt;,代码如下:</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">(注:style中的#main对应body中的id=main, .main对应class=main)</span></p><span style="color: black;">&lt;!DOCTYPE <span style="color: black;">html</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">html</span> <span style="color: black;">lang</span>=<span style="color: black;">"en"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">head</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">meta</span> <span style="color: black;">charset</span>=<span style="color: black;">"UTF-8"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">title</span>&gt;</span>Title<span style="color: black;">&lt;/<span style="color: black;">title</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">style</span>&gt;</span><span style="color: black;">
      <span style="color: black;">#intro</span> {
      <span style="color: black;">display</span>: -webkit-flex; <span style="color: black;">/* Safari */</span>
      <span style="color: black;">display</span>: flex;
      <span style="color: black;">justify-content</span>: center;
      }
      <span style="color: black;">.peo</span> {
      <span style="color: black;">max-width</span>: <span style="color: black;">10rem</span>;
      <span style="color: black;">border-bottom</span>: <span style="color: black;">0.2rem</span>solid<span style="color: black;">#000000</span>;
      <span style="color: black;">font-family</span>: sans-serif;
      <span style="color: black;">font-size</span>: <span style="color: black;">1.5rem</span>;
      <span style="color: black;">color</span>: <span style="color: black;">#0070C0</span>;
      <span style="color: black;">line-height</span>: <span style="color: black;">3rem</span>;
      }
    </span><span style="color: black;">&lt;/<span style="color: black;">style</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">head</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">body</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">div</span> <span style="color: black;">id</span>=<span style="color: black;">"intro"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">p</span> <span style="color: black;">class</span>=<span style="color: black;">"peo"</span>&gt;</span><span style="color: black;">名人</span>介绍<span style="color: black;">&lt;/<span style="color: black;">p</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">div</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">div</span> <span style="color: black;">id</span>=<span style="color: black;">"pic1"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">div</span> <span style="color: black;">class</span>=<span style="color: black;">"bord"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">img</span> <span style="color: black;">class</span>=<span style="color: black;">"img"</span> <span style="color: black;">src</span>=<span style="color: black;">"pic/Taylor.png"</span>/&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">p</span> <span style="color: black;">class</span>=<span style="color: black;">"word"</span>&gt;</span>Taylor<span style="color: black;">&lt;/<span style="color: black;">p</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">div</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">div</span> <span style="color: black;">class</span>=<span style="color: black;">"bord"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">img</span> <span style="color: black;">class</span>=<span style="color: black;">"img"</span> <span style="color: black;">src</span>=<span style="color: black;">"pic/yan.png"</span>/&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">p</span> <span style="color: black;">class</span>=<span style="color: black;">"word"</span>&gt;</span>东<span style="color: black;">&lt;/<span style="color: black;">p</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">div</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">div</span> <span style="color: black;">class</span>=<span style="color: black;">"bord"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">img</span> <span style="color: black;">class</span>=<span style="color: black;">"img"</span> <span style="color: black;">src</span>=<span style="color: black;">"pic/song.png"</span>/&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">p</span> <span style="color: black;">class</span>=<span style="color: black;">"word"</span>&gt;</span>乔<span style="color: black;">&lt;/<span style="color: black;">p</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">div</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">div</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">body</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">html</span>&gt;</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">运行结果:</span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/130f769c84634388b1e843e0cb34fab0~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722664155&amp;x-signature=TyiUmniQ1woEWgVk0SiEwLmeX5Q%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">2)<span style="color: black;">照片</span>部分是3个&lt;div class=bord&gt;横向展示,<span style="color: black;">因此</span>要在框住它们的&lt;div id=pic1&gt;样式中设置flex布局,在&lt;style&gt;里加入以下代码:</span></p><span style="color: black;">#pic1</span> {
    <span style="color: black;">display</span>: -webkit-flex; <span style="color: black;">/* Safari */</span>
    <span style="color: black;">display</span>: flex;
    <span style="color: black;">justify-content</span>: center;
    }<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">运行结果:</span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/e5befb0da1194b3592d6c2a89d92d752~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722664155&amp;x-signature=PQLaVWTh%2BIJ8ewXx88a%2BVLv5P%2BI%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">3)<span style="color: black;">照片</span>之间靠太近,<span style="color: black;">照片</span><span style="color: black;">体积</span>不一致,文字没居中,<span style="color: black;">咱们</span>在&lt;style&gt;里加入以下代码:</span></p><span style="color: black;">.bord</span>{
    <span style="color: black;">padding</span>: <span style="color: black;">1rem</span> <span style="color: black;">2rem</span>;
    }


    <span style="color: black;">.img</span> {
    <span style="color: black;">border</span>: <span style="color: black;">0.2rem</span> solid <span style="color: black;">#e3e3e3</span>;
    <span style="color: black;">max-width</span>: <span style="color: black;">15rem</span>;
    <span style="color: black;">height</span>: <span style="color: black;">22rem</span>;
    }


    <span style="color: black;">.word</span> {
    <span style="color: black;">text-align</span>: center;
    }<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">运行结果:</span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/eaa9b0d491a8475792cbc0af8daf0217~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1722664155&amp;x-signature=GIMEkWrGqsHPXr5hUvS%2Bpl4%2FLyo%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">5、</span>总 结</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">今天<span style="color: black;">咱们</span>学会了flex布局,今后所有的网页排版都<span style="color: black;">能够</span>实现了,祝愿<span style="color: black;">大众</span>都有所收获,完整的代码如下:</span></p><span style="color: black;">&lt;!DOCTYPE <span style="color: black;">html</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">html</span> <span style="color: black;">lang</span>=<span style="color: black;">"en"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">head</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">meta</span> <span style="color: black;">charset</span>=<span style="color: black;">"UTF-8"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">title</span>&gt;</span>Title<span style="color: black;">&lt;/<span style="color: black;">title</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">style</span>&gt;</span><span style="color: black;">
      <span style="color: black;">#intro</span> {
      <span style="color: black;">display</span>: -webkit-flex; <span style="color: black;">/* Safari */</span>
      <span style="color: black;">display</span>: flex;
      <span style="color: black;">justify-content</span>: center;


      }

      <span style="color: black;">.peo</span> {
      <span style="color: black;">max-width</span>: <span style="color: black;">10rem</span>;
      <span style="color: black;">border-bottom</span>: <span style="color: black;">0.2rem</span>solid<span style="color: black;">#000000</span>;
      <span style="color: black;">font-family</span>: sans-serif;
      <span style="color: black;">font-size</span>: <span style="color: black;">1.5rem</span>;
      <span style="color: black;">color</span>: <span style="color: black;">#0070C0</span>;
      <span style="color: black;">line-height</span>: <span style="color: black;">3rem</span>;
      }

      <span style="color: black;">#pic1</span> {
      <span style="color: black;">display</span>: -webkit-flex; <span style="color: black;">/* Safari */</span>
      <span style="color: black;">display</span>: flex;
      <span style="color: black;">justify-content</span>: center;
      }

      <span style="color: black;">.bord</span>{
      <span style="color: black;">padding</span>: <span style="color: black;">1rem</span> <span style="color: black;">2rem</span>;
      }

      <span style="color: black;">.img</span> {
      <span style="color: black;">border</span>: <span style="color: black;">0.2rem</span> solid <span style="color: black;">#e3e3e3</span>;
      <span style="color: black;">max-width</span>: <span style="color: black;">15rem</span>;
      <span style="color: black;">height</span>: <span style="color: black;">22rem</span>;
      }

      <span style="color: black;">.word</span> {
      <span style="color: black;">text-align</span>: center;
      }</span><span style="color: black;">&lt;/<span style="color: black;">style</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">head</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">body</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">div</span> <span style="color: black;">id</span>=<span style="color: black;">"intro"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">p</span> <span style="color: black;">class</span>=<span style="color: black;">"peo"</span>&gt;</span><span style="color: black;">名人</span>介绍<span style="color: black;">&lt;/<span style="color: black;">p</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">div</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">div</span> <span style="color: black;">id</span>=<span style="color: black;">"pic1"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">div</span> <span style="color: black;">class</span>=<span style="color: black;">"bord"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">img</span> <span style="color: black;">class</span>=<span style="color: black;">"img"</span> <span style="color: black;">src</span>=<span style="color: black;">"pic/Taylor.png"</span>/&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">p</span> <span style="color: black;">class</span>=<span style="color: black;">"word"</span>&gt;</span>Taylor<span style="color: black;">&lt;/<span style="color: black;">p</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">div</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">div</span> <span style="color: black;">class</span>=<span style="color: black;">"bord"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">img</span> <span style="color: black;">class</span>=<span style="color: black;">"img"</span> <span style="color: black;">src</span>=<span style="color: black;">"pic/yan.png"</span>/&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">p</span> <span style="color: black;">class</span>=<span style="color: black;">"word"</span>&gt;</span>东<span style="color: black;">&lt;/<span style="color: black;">p</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">div</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">div</span> <span style="color: black;">class</span>=<span style="color: black;">"bord"</span>&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">img</span> <span style="color: black;">class</span>=<span style="color: black;">"img"</span> <span style="color: black;">src</span>=<span style="color: black;">"pic/song.png"</span>/&gt;</span>
    <span style="color: black;">&lt;<span style="color: black;">p</span> <span style="color: black;">class</span>=<span style="color: black;">"word"</span>&gt;</span>乔<span style="color: black;">&lt;/<span style="color: black;">p</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">div</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">div</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">body</span>&gt;</span>
    <span style="color: black;">&lt;/<span style="color: black;">html</span>&gt;</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">今天的知识比较<span style="color: black;">基本</span>但非常实用,<span style="color: black;">每日</span>学会一个小技能,积少成多,以后就能<span style="color: black;">作为</span>大神。<span style="color: black;">倘若</span><span style="color: black;">大众</span>对网页上的实现有什么不懂的,尽请留言,OF<span style="color: black;">必定</span>会一一解答的。</span></p>




听听海 发表于 2024-8-26 09:18:40

感谢你的精彩评论,带给我新的思考角度。

1fy07h 发表于 2024-10-1 07:14:32

你的话语如春风拂面,温暖了我的心房,真的很感谢。

nqkk58 发表于 2024-11-14 11:18:44

期待与你深入交流,共探知识的无穷魅力。
页: [1]
查看完整版本: 学会用HTML-flex布局制作美丽的网页