<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        如何使用Flexbox構建新聞站點布局_html/css_WEB-ITnose

        來源:懂視網 責編:小采 時間:2020-11-27 16:40:55
        文檔

        如何使用Flexbox構建新聞站點布局_html/css_WEB-ITnose

        如何使用Flexbox構建新聞站點布局_html/css_WEB-ITnose:英文原文: http://webdesign.tutsplus.com/tutorials/how-to-build-a-news-website-layout-with-flexbox--cms-26611 Its not necessary to understand every aspect of Flexbox before you
        推薦度:
        導讀如何使用Flexbox構建新聞站點布局_html/css_WEB-ITnose:英文原文: http://webdesign.tutsplus.com/tutorials/how-to-build-a-news-website-layout-with-flexbox--cms-26611 Its not necessary to understand every aspect of Flexbox before you
        英文原文: http://webdesign.tutsplus.com/tutorials/how-to-build-a-news-website-layout-with-flexbox--cms-26611

        It’s not necessary to understand every aspect of Flexbox before you can jump in and get started. In this tutorial, we’re going to introduce a few features of Flexbox whilst designing a “news layout” like the one you can find on The Guardian .

        The reason we’re using Flexbox is that it provides very powerful features:

      1. we can easily make responsive columns
      2. we can make columns of equal height
      3. we can push content to the bottom of a container
      4. So let’s get started!

        1. Start with Two Columns

        Creating columns in CSS has always been a challenge. For a long time, the only options were to use floats or tables, but they both had their own issues.

        Flexbox makes the process easier, giving us:

      5. cleaner code : we only need a container with display: flex
      6. no need to clear floats, preventing unexpected layout behavior
      7. semantic markup
      8. flexibility : we can resize, stretch, align the columns in a few lines of CSS
      9. Let’s start by making two columns; one that’s 2/3 of the width of our container, and one that’s 1/3.

         2/3 column 1/3 column 

        There are two elements here:

      10. the columns container
      11. two column children, one with an additional class of main-column which we’ll use to make it wider
      12. .columns { display: flex;}.column { flex: 1;}.main-column { flex: 2;}

        As the main column has a flex value of 2, it will take up twice as much space as the other column.

        By adding some additional visual styles, here’s what we get:

        2. Make Each Column a Flexbox Container

        Each of these two columns will contain several articles stacked vertically, so we’re going to turn the column elements into Flexbox containers too. We want:

      13. the articles to be stacked vertically
      14. the articles to stretch and fill the available space
      15. .column { display: flex; flex-direction: column; /* Makes the articles stacked vertically */}.article { flex: 1; /* Stretches the articles to fill up the remaining space */}

        The flex-direction: column rule on the container, combined with the flex: 1 rule on the children ensures that the articles will fill up the whole vertical space, keeping our first two columns the same height.

        3. Make Each Article a Flexbox Container

        Now, to give us extra control, let’s turn each article into a Flexbox container too. Each of them will contain:

      16. a title
      17. a paragraph
      18. an information bar with the author and the number of comments
      19. an optional responsive image
      20. We’re using Flexbox here in order to “push” the information bar to the bottom. As a reminder, this is the article layout we’re aiming for:

        Here’s the code:

         

        .article { display: flex; flex-direction: column; flex-basis: auto; /* sets initial element size based on its contents */}.article-body { display: flex; flex: 1; flex-direction: column;}.article-content { flex: 1; /* This will make the content fill up the remaining space, and thus push the information bar at the bottom */}

        The article’s elements are laid out vertically thanks to the flex-direction: column; rule.

        We apply flex: 1 to the article-content element so that it fills up the empty space, and “pushes” the article-info to the bottom, no matter the height of the columns.

        4. Add Some Nested Columns

        In the left column, what we actually want is another set of columns. So we’re going to replace the second article with the same columns container we’ve already used.

         

        As we want the first nested column to be wider, we’re adding a nested-column class with the additional style:

        .nested-column { flex: 2;}

        This will make our new column twice as wide as the other.

        5. Give the First Article a Horizontal Layout

        The first article is really big. To optimize the use of space, let’s switch its layout to be horizontal.

        .first-article { flex-direction: row;}.first-article .article-body { flex: 1;}.first-article .article-image { height: 300px; order: 2; padding-top: 0; width: 400px;}

        The order property is very useful here, as it allows us to alter the order of HTML elements without affecting the HTML markup. The article-image actually comes before the article-body in the markup, but it will behave as if it comes after.

        6. Make the Layout Responsive

        This is all looking just as we want, though it’s a bit squished. Let’s fix that by going responsive.

        One great feature of Flexbox is that you need only remove the display: flex rule on the container to disable Flexbox completely, while keeping all the other Flexbox properties (such as align-items or flex) valid.

        As a result, you can trigger a “responsive” layout by enabling Flexbox only above a certain breakpoint.

        We’re going to remove display: flex from both the .columns and .column selectors, instead wrapping them in a media query:

        @media screen and (min-width: 800px) { .columns, .column { display: flex; }}

        That’s it! On smaller screens, all the articles will be on top of each other. Above 800px, they will be laid out in two columns.

        7. Add Finishing Touches

        To make the layout more appealing on larger screens, let’s add some CSS tweaks:

        @media screen and (min-width: 1000px) { .first-article { flex-direction: row; } .first-article .article-body { flex: 1; } .first-article .article-image { height: 300px; order: 2; padding-top: 0; width: 400px; } .main-column { flex: 3; } .nested-column { flex: 2; }}

        The first article has its content laid out horizontally, with the text on the left and the image on the right. Also, the main column is now wider (75%) and the nested column too (66%). Here’s the final result!

        Conclusion

        I hope I’ve shown you that you needn’t understand every aspect of Flexbox to jump in and start using it! This responsive news layout is a really useful pattern; pull it apart, play with it, let us know how you get on!

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        如何使用Flexbox構建新聞站點布局_html/css_WEB-ITnose

        如何使用Flexbox構建新聞站點布局_html/css_WEB-ITnose:英文原文: http://webdesign.tutsplus.com/tutorials/how-to-build-a-news-website-layout-with-flexbox--cms-26611 Its not necessary to understand every aspect of Flexbox before you
        推薦度:
        標簽: 如何用 flex it
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 免费在线看片网站| 国产一区二区三区免费视频 | 中文字幕在线免费播放| 免费无码成人AV片在线在线播放| 亚洲视频免费在线看| 亚洲一区免费视频| 亚洲美免无码中文字幕在线| 最近2018中文字幕免费视频 | 亚洲国产美女精品久久久久∴| 全黄A免费一级毛片| gogo全球高清大胆亚洲| 一级做a爱过程免费视| 国产亚洲美女精品久久久2020| 久久一区二区三区免费| 亚洲AV无码国产精品麻豆天美 | 亚洲精品偷拍视频免费观看| eeuss影院免费直达入口| 亚洲人成在线播放网站| 久久综合九色综合97免费下载| 亚洲免费在线观看视频| 日韩精品视频免费观看| 国产亚洲情侣久久精品| 亚洲精品无码乱码成人| 污视频在线免费观看| 亚洲精品无码中文久久字幕| 国产亚洲美女精品久久久| 无码AV片在线观看免费| 亚洲熟妇无码一区二区三区| 精品国产人成亚洲区| 久久99热精品免费观看牛牛| 亚洲综合小说另类图片动图| 亚洲国产免费综合| 3344免费播放观看视频 | 亚洲Av永久无码精品黑人| 国产国拍亚洲精品福利 | 又黄又爽又成人免费视频| 黄色网址大全免费| 亚洲视频手机在线| 免费少妇a级毛片| 91精品免费国产高清在线| 免费看一级毛片在线观看精品视频|