CSS 및 미디어 쿼리는 웹 탐색 기능을 구현합니다(코드 첨부).

php中世界最好的语言
풀어 주다: 2018-05-07 17:38:22
원래의
2956명이 탐색했습니다.

이번에는 웹 탐색 기능을 구현하기 위한 CSS와 미디어 쿼리를 다루겠습니다. CSS와 미디어 쿼리를 사용하여 웹 탐색 기능을 구현하는 경우 주의 사항은 무엇입니까? 보세요.

렌더링이 첨부되어 있으니 기분이 좋으시다면 구현 코드를 참고하세요:

코드는 다음과 같습니다. 복사해서 사용하세요:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        body {
            background: #801638;
        }
        body,
        body > * {
            margin: 0;
            padding: 0;
            font-family: 'Roboto', sans-serif;
            font-weight: normal;
        }
        * {
            transition: all .3s ease 0s;
        }
        /* Background colours */
        p + p article:nth-child(1) {
            background: #c22326;
        }
        p + p article:nth-child(2) {
            background: #f37338;
        }
        p + p article:nth-child(3) {
            background: #fdb632;
        }
        p + p article:nth-child(4) {
            background: #027878;
        }
        p + p article:nth-child(5),
        p + p {
            background: #801638;
        }
        /* Main layout */
        html,
        body,
        p + p {
            width: 100vw;
            height: 100vh;
        }
        p + p {
            list-style: none;
            position: relative;
            display: flex;
            flex-direction: row;
            flex-wrap: nowrap;
            align-items: stretch;
            overflow: hidden;
        }
        /* Articles */
        p + p article {
            flex: initial;
            width: 20%;
            height: 100%;
            text-align: center;
            color: #fff;
            text-decoration: none;
            vertical-align: bottom;
            box-sizing: border-box;
            padding: 2vh 1vw;
            position: relative;
        }
        /* Big Headings */
        body > p:first-child {
            position: fixed;
            bottom: 8vh;
            background: #fff;
            width: 100%;
            text-align: center;
            padding: .5rem;
            z-index: 2;
        }
        body > p:first-child h1,
        body > p:first-child h2 {
            margin: 0;
            padding: 0;
        }
        /* Hover interaction */
        p + p:hover article {
            flex: initial;
            width: 10%;
        }
        p + p article:hover {
            width: 60%;
        }
        article > p {
            opacity: 0;
            transition: opacity .2s ease 0;
        }
        p + p article:hover > p {
            opacity: 1;
            transition: opacity .3s ease .3s;
        }
        /* navigation */
        p + p article > h2 {
            bottom: 2vh;
            position: absolute;
            text-align: center;
            width: 100%;
            margin: 0;
            font-size: 3vh;
        }
        /* Article layouts */
        article p {
            text-align: left;
            width: 58vw;
        }
        article p p,
        article p p h2,
        article p h3 {
            margin: 0 0 1em 0;
        }
        article p p {
            width: 40vw;
        }
        @media (max-width: 900px) {
            p + p article {
                padding: 2vh 3vw;
            }
            p + p article > h2 {
                transform: rotate(90deg);
                bottom: 23vh;
                min-width: 12em;
                text-align: left;
                transform: rotate(-90deg);
                transform-origin: 0 0 0;
                opacity: 1;
            }
            p + p article:hover > h2 {
                opacity: 0;
            }
            article p p {
                width: 50vw;
            }
            article p {
                max-height: calc(72%);
                overflow-y: auto;
            }
        }
    </style>
</head>
<body>
    <p>
        <h1>我在这,谁敢动我。</h1>
        <h2>我是你们大哥的头</h2>
    </p>
    <p>
        <article>
            <h2>大哥的小弟一</h2>
            <p>
                <h3>大哥的小弟一</h3>
                <p>身高180</p>
                <p>体重120</p>
            </p>
         </article>
         <article>
           <h2>大哥的小弟二</h2>
            <p>
               <h3>大哥的小弟二</h3>
               <p>身高160</p>
               <p>体重100</p>
            </p>
          </article>
          <article>
             <h2>大哥的小弟三</h2>
             <p>
               <h3>大哥的小弟三</h3>
               <p>身高175</p>
               <p>体重180</p>
             </p>
          </article>
          <article>
             <h2>大哥的小弟四</h2>
             <p>
               <h3>大哥的小弟四</h3>
                 <p>身高180</p>
                 <p>体重110</p>
             </p>
          </article>
          <article>
             <h2>大哥的小弟五</h2>
             <p>
               <h3>大哥的小弟五</h3>
               <p>身高180</p>
               <p>体重150</p>
             </p>
          </article>
     </p>
  </body>
</html>
로그인 후 복사

이 케이스를 읽으신 후 방법을 마스터하셨으리라 믿습니다. 기사. 더 흥미로운 내용을 보려면 중국 웹사이트의 PHP 기타 관련 기사를 주목하세요!

추천 도서:

노드 디버깅 도구 사용에 대한 자세한 설명

웹팩 패키징 및 js 및 css 압축 단계에 대한 자세한 설명

위 내용은 CSS 및 미디어 쿼리는 웹 탐색 기능을 구현합니다(코드 첨부).의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
최신 이슈
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!