整合營銷服務商

          電腦端+手機端+微信端=數據同步管理

          免費咨詢熱線:

          手把手教你常見的CSS布局方式「實踐」


          者:sunshine小小倩

          轉發鏈接:https://juejin.im/post/599970f4518825243a78b9d5

          TML5實現頭像的上傳

          這是利用form-data給后臺傳輸數據,來實現頭像的上傳加載!

          1. html代碼
          <!DOCTYPE html>
          <html lang="en">
          <head>
              <meta charset="UTF-8">
              <meta name="viewport" content="width=, initial-scale=1.0">
              <meta http-equiv="X-UA-Compatible" content="ie=edge">
              <title>Document</title>
              </head>
          <body>
              <div class="container">
                  <input enctype="multipart/form-data" type="file">
                  <input id="Susername"  type="text" placeholder="用戶名">
                  <input id="Ssex" type="number" placeholder="年齡">
                  <input id="Sage" type="text" placeholder="專業">
                  <input id="Smajor" type="text" placeholder="學校">
                  <input id="Sschool" type="text" placeholder="QQ">
                  <input id="Sqq" type="text" placeholder="地址">
                  <input id="Saddress" type="text" placeholder="座右銘">
                  <input id="Smotto" type="button" value="上傳">
                 
                  <div style="clear: both;"></div>
                       <progress value="0" max="100"></progress>
              </div>
              <div class="showarea">
                  <h3>顯示區域</h3>
              </div>
              </body>
          </html>
          
          1. 樣式代碼
           .container{
                      box-sizing: border-box;
                      width: 404px;
                      height: 100px;
                      border: 1px solid #ccc;
                      border-radius: 5px;
                      padding-top: 20px;
                      background: linear-gradient(to bottom,#0ff,#0ff 20px,transparent 0);
                      margin: 0 auto;
                  }
                  input{
                      padding: 0;
                      margin: 0;
                    
                  }
                  .container input[type=file]{
                      width: 300px;
                      height: 30px;
                      border: 1px solid #ccc;
                      background: #7FFFD4;
                      color: #133131;
                      float: left;
                  }
                  .container input[typr=button]{
                      width: 100px;
                      height: 32px;
                      float: left;
                      border: 1px solid #ccc;
                      color:  #133131;
                  }
                  progress{
                      display: none;
                      width: 400px;
                      height: 30px;
                      margin-top: 7px;
                  }
                  .showarea{
                      width: 600px;
                      min-height: 200px;
                      border: 1px solid #ccc;
                      margin: 30px auto;
                  }
                  .showarea h3{
                      widows: 100px;
                      margin: 0 auto;
                      line-height: 60px;
                      text-align: center;
                      border-bottom: 1px solid #cccc;
                      color: #133131;
                      
                  }
                  .showareaimg{
                      max-width: 1000%;
                  }
          
          1. javescript代碼

          在現代網頁設計中,個人主頁是一個展示個人信息、技能、事件等的重要載體。為了吸引訪客的注意力并提供良好的用戶體驗,設計師通常會運用各種技巧和效果來增加頁面的吸引力。本文將介紹如何使用CSS創建一個驚嘆的個人主頁介紹卡片,展示獨特魅力;

          PREVIEW

          創建HTML結構

          首先,需要定義基本的HTML結構來容納個人主頁介紹卡片;

          這里外層使用一個div包裹,里面使用三個<div>元素作為包裹容器布局,并在其中添加所需的圖像、內容和按鈕等:

          <div class="card">
            <div class="box">
              <div class="img_box">
                <video 
                  src="./assets/video.mp4"
                  muted
                  autoplay
                  loop
                />
              </div>
            </div>
          
            <div class="box">
              <div class="content">
                <h2>
                  Alexa
                  <br>
                  <span>
                    Professional Artist
                  </span>
                </h2>
          
                <ul>
                  <li>
                    Posts
                    <span>22</span>
                  </li>
                  <li>
                    Followers
                    <span>999+</span>
                  </li>
                  <li>
                    Following
                    <span>7</span>
                  </li>
                </ul>
          
                <button>Follow</button>
              </div>
            </div>
          
            <div class="circle">
              <div class="img_box">
                <img src="./assets/user.jpg" alt="">
              </div>
            </div>
          </div>


          外層是card容器,視頻和文本內容區域是上下布局的,分別使用box容器包裹,最后是circle容器包裹頭像在定位在中間左邊超出;

          注:

          video設置屬性:靜音(muted)可實現自動播放(autoplay),接著設置循環播放(loop);

          img>和video>的父容器是一個類名img_box;

          添加元素樣式

          接下來,我們將使用CSS來為個人主頁介紹卡片添加樣式。以下是一些關鍵的樣式屬性和技巧,可以使卡片看起來更加漂亮和吸引人;

          Base CSS

          • 使用通配符選擇器*來為頁面中的所有元素設置相同的樣式,清除默認樣式,使用怪異盒子模型;
          • 選擇文檔的根元素(HTML中的 <html>)定義顏色CSS變量;
          • body使用flex把card容器布局在頁面水平、垂直居中;
          • card使用flex把三個子容器實現垂直排列并兩端對齊;
          * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
          }
          
          :root {
            --clr: #083d41
          }
          
          body {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background-color: var(--clr);
          }
          
          .card {
            background-color: var(--clr);
            position: relative;
          
            width: 320px;
            height: 430px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
          }
          
          /* 先把容器基本樣式調整一下 */
          .card .box {
            background-color: tomato;
            position: relative;
            
            width: 110%;
            height: 200px;
            /* 文本內容區域圓角 */
            border-radius: 20px;
          }
          
          /* 頭像容器則使用定位布局 */
          .card .circle {
            width: 180px;
            height: 180px;
            position: absolute;
            left: -70px;
            top: 50%;
            transform: translateY(-50%);
            border-radius: 50%;
            border: 10px solid var(--clr);
          }
          
          /* 調整img和video共有的父容器樣式 */
          .card .box .img_box,
          .card .circle .img_box {
            position: absolute;
            inset: 0;
            overflow: hidden;
            /* img的圓角 */
            border-radius: 50%; 
          }
          .card .box .img_box {
            /* video的圓角 */
            border-radius: 15px;
          }
          
          /* 調整圖片和視頻的樣式 */
          .card .box .img_box video,
          .card .circle .img_box img {
            position: absolute;
            width: 100%;
            height: 100%;
            object-fit: cover;
          }

          視頻區域CSS

          調整card下的第一個box容器樣式,也就是包裹視頻的容器:

          • 包圍圖片的邊框部分,優化成圓角使其看上去不是那么突兀;
          • 使用::before,::after創建兩個偽元素用于需要優化的兩角;
          • 設置偽元素的左下角邊框圓角程度與box保持一致,當然也可以自行調整;
          • 最后給偽元素添加陰影效果覆蓋住box的角,然后陰影顏色設置為與背景色一致,就能實現了: 屬性可設置的值包括陰影的 X 軸偏移量、Y 軸偏移量、模糊半徑、擴散半徑和顏色; 比如本次設置的值對應:X軸偏移-6px Y軸偏移6px 顏色;


          .card .box:nth-child(1)::before {
            content: "";
            width: 20px;
            height: 20px;
            background-color: transparent;
            
            position: absolute;
            z-index: 10;
            top: 106px;
            left: -1px;
            border-bottom-left-radius: 20px;
            box-shadow: -6px 6px var(--clr);
          }
          
          /* 樣式同before類似,注意定位樣式 */
          .card .box:nth-child(1)::after {
            content: "";
            width: 20px;
            height: 20px;
            background-color: transparent;
            
            position: absolute;
            z-index: 10;
            bottom: -1px;
            left: 105px;
            border-bottom-left-radius: 20px;
            box-shadow: -6px 6px var(--clr);
          }

          目前添加樣式效果圖,可以在調試階段更改明顯色彩用于調整距離、位置等;

          文本內容CSS

          調整card下的第二個box容器樣式,也就是包含文字信息的容器:

          • 包圍圖片的邊框部分,優化成圓角樣式同上面類似,部分需要調整的看代碼;
          • 注意這里設置的是偽元素的左上角圓角程度,然后添加陰影顏色實現;
          • 此外,還對卡片內部的標題、段落和列表應用了特定的樣式,以使其在視覺上更加吸引人;


          .card .box:nth-child(2) {
            background-color: #fff;
          
            width: 100%;
            height: 220px;
          }
          
          .card .box:nth-child(2)::before {
            content: "";
            width: 20px;
            height: 20px;
            background-color: transparent;
          
            position: absolute;
            z-index: 10;
            bottom: 106px;
            left: -1px;
            border-top-left-radius: 20px;
            box-shadow: -6px -6px var(--clr);
          }
          .card .box:nth-child(2)::after {
            content: "";
            width: 20px;
            height: 20px;
            background-color: transparent;
          
            position: absolute;
            z-index: 10;
            top: -1px;
            left: 109px;
            border-top-left-radius: 20px;
            box-shadow: -6px -6px var(--clr);
          }
          
          .card .box .content {
            position: absolute;
            inset: 0;
            padding: 30px 10px 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 20px;
          }
          
          /* 姓名和Title樣式 */
          .card .box .content h2 {
            width: 100%;
            padding-left: 120px;
            text-transform: uppercase;
            letter-spacing: 0.1em;
            line-height: 1.1em;
            font-size: 1.15em;
            font-weight: 600;
            color: #333;
          }
          .card .box .content h2 span {
            letter-spacing: 0.05em;
            font-size: 0.75em;
            font-weight: 400;
            color: tomato;
            text-transform: initial;
          }
          
          /* 列表樣式 */
          .card .box .content ul {
            position: relative;
            top: 15px;
          
            width: 100%;
            padding: 0 10px;
            display: grid;
            grid-template-columns: repeat(3, 1fr);
          }
          .card .box .content ul li {
            list-style: none;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 0 10px;
            font-size: 0.85em;
            font-weight: 500;
            color: #999;
          }
          .card .box .content ul li:not(:last-child)
          {
           border-right: 1px solid #ccc; 
          }
          .card .box .content ul li span{
            font-size: 1.65em;
            color: #333;
          }
          
          /* 按鈕樣式 */
          .card .box .content button {
            position: relative;
            top: 25px;
            padding: 8px 30px;
            border: none;
            outline: none;
            background-color: #03a9f4;
            border-radius: 30px;
            color: #fff;
            font-size: 1em;
            letter-spacing: 0.2em;
            text-transform: uppercase;
            font-weight: 500;
            cursor: pointer;
            border: 5px solid var(--clr);
            box-shadow: 0 0 0 10px #fff;
            transition: .5s;
          }
          .card .box .content button:hover {
            letter-spacing: 0.5em;
            background-color: #ff3d7f;
          }

          進一步優化

          由于按鈕的圓角與文本內容卡片的交界處看上去顯得有些過于突兀了; 所以現在把它們的交界處優化成弧形,樣式類似box的偽元素,這里也給按鈕創建兩個偽元素,用于優化兩邊的交界處:

          .card .box .content button::before {
            content: "";
            width: 20px;
            height: 20px;
            background-color: transparent;
            position: absolute;
            top: 23px;
            left: -29px;
            border-top-right-radius: 20px;
            box-shadow: 5px -7px #fff;
          }
          
          .card .box .content button::after {
            content: "";
            width: 20px;
            height: 20px;
            background-color: transparent;
            position: absolute;
            top: 23px;
            right: -29px;
            border-top-left-radius: 20px;
            box-shadow: -5px -7px #fff;
          }

          最后

          除了基本樣式之外,還進一步優化個人主頁介紹卡片的細節。一些可選的技巧包括:

          • 添加過渡效果:通過為button的容器元素添加過渡效果,使卡片在鼠標懸停時平滑地改變樣式(背景色、字符間距);
          • 使用偽元素添加box-shadow技巧覆蓋比較突兀的地方,使各個元素之間的交界處有過渡感,可以增加視覺上的吸引力;
          • 通過給元素設置與body背景相同的顏色,可以使其在頁面中更加突出和立體;

          通過運用CSS的各種樣式屬性和技巧,我們可以輕松地創建漂亮的個人主頁介紹卡片。這些卡片不僅能夠有效地展示個人信息和技能,還能夠吸引訪客的注意力并提供良好的用戶體驗。記得嘗試不同的樣式和效果來定制你自己獨特的個人主頁卡片!


          CSS創作個人主頁介紹卡片,展示獨特魅力
          原文鏈接:https://juejin.cn/post/7260709771870060603


          主站蜘蛛池模板: 亚洲欧美日韩中文字幕一区二区三区| 全国精品一区二区在线观看| 精品欧美一区二区在线观看| 福利一区二区在线| 无码少妇一区二区| 乱中年女人伦av一区二区| av无码免费一区二区三区| 久久精品一区二区国产| 中文字幕一区精品| 国产精品免费综合一区视频| 亚洲午夜精品一区二区麻豆| 亚洲综合无码一区二区| 精品久久一区二区三区| 国产成人无码AV一区二区在线观看 | 亚洲AV无码一区二三区| 中日av乱码一区二区三区乱码| 国产成人一区二区精品非洲| 免费看无码自慰一区二区| 亚洲一区二区三区高清在线观看| 亚洲一区二区三区久久久久| ...91久久精品一区二区三区 | 国产精品一区二区三区久久| 激情无码亚洲一区二区三区| 日本大香伊一区二区三区| asmr国产一区在线| 亚洲国产成人久久一区WWW| 国产精品久久亚洲一区二区| 国产成人一区二区动漫精品| 国产精品亚洲一区二区三区久久 | 乱子伦一区二区三区| 人妻体体内射精一区二区| 亚洲国产一区二区三区青草影视 | 日本强伦姧人妻一区二区| 一区二区三区四区精品| 久久精品无码一区二区日韩AV| 亚洲色欲一区二区三区在线观看 | 国产一区二区三区高清视频| 国产亚洲一区二区在线观看| 精品无码AV一区二区三区不卡| 国产日本亚洲一区二区三区| 日韩视频一区二区在线观看|