简体   繁体   English

为什么弹性方向不从行到列

[英]Why isn't the flex-direction going from row to column

I'm coding using the Front-ENd Web Development [The Big Nerd Ranch Guide] book to help me better understand css and javascript. 我正在使用Front-ENd Web开发[The Big Nerd Ranch Guide]一书进行编码,以帮助我更好地理解css和javascript。 There's a project where I'm learning how to use media queries and im suppose to changed the flex-direction property from a row to a column. 在一个项目中,我正在学习如何使用媒体查询,并且想将flex-direction属性从行更改为列。 I've copied the code as its shown and for some odd reason the code doesn't change the direction. 我已经复制了代码,如图所示,出于某种奇怪的原因,代码没有改变方向。 It Follows everything before and after that piece of code. 它遵循这段代码之前和之后的所有内容。 I'm hoping a extra pair of eyes can help me spot where I went wrong and help me understand media-queries & flexbox better. 我希望额外的一双眼睛可以帮助我找出问题所在,并帮助我更好地理解媒体查询和Flexbox。

    <main class="main-content">
    <ul class="thumbnail-list">

      <li class="thumbnail-item">
        <a href="#">
          <img src="img/otter1.jpg" alt="Barry The Otter" class="thumbnail-image">
          <span class="thumbnail-title">Barry</span>
        </a>
      </li>

      <li class="thumbnail-item">
        <a href="#">
          <img src="img/otter2.jpg" alt="Robin The Otter" class="thumbnail-image">
          <span class="thumbnail-title">Robin</span>
        </a>
      </li>

      <li class="thumbnail-item">
        <a href="#">
          <img src="img/otter3.jpg" alt="Maurice The Otter" class="thumbnail-image">
          <span class="thumbnail-title">Maurice</span>
        </a>
      </li>

      <li class="thumbnail-item">
        <a href="#">
          <img src="img/otter4.jpg" alt="Lesley The Otter" class="thumbnail-image">
          <span class="thumbnail-title">Lesley</span>
        </a>
      </li>

      <li class="thumbnail-item">
        <a href="#">
          <img src="img/otter5.jpg" alt="Barbara The Otter" class="thumbnail-image">
          <span class="thumbnail-title">Barbara</span>
        </a>
      </li>



      <li class="thumbnail-item">
        <a href="#">
          <img src="img/otter1.jpg" alt="Barry The Otter" class="thumbnail-image">
          <span class="thumbnail-title">Barry</span>
        </a>
      </li>

      <li class="thumbnail-item">
        <a href="#">
          <img src="img/otter2.jpg" alt="Robin The Otter" class="thumbnail-image">
          <span class="thumbnail-title">Robin</span>
        </a>
      </li>

      <li class="thumbnail-item">
        <a href="#">
          <img src="img/otter3.jpg" alt="Maurice The Otter" class="thumbnail-image">
          <span class="thumbnail-title">Maurice</span>
        </a>
      </li>

      <li class="thumbnail-item">
        <a href="#">
          <img src="img/otter4.jpg" alt="Lesley The Otter" class="thumbnail-image">
          <span class="thumbnail-title">Lesley</span>
        </a>
      </li>

      <li class="thumbnail-item">
        <a href="#">
          <img src="img/otter5.jpg" alt="Barbara The Otter" class="thumbnail-image">
          <span class="thumbnail-title">Barbara</span>
        </a>
      </li>

    </ul>
______________________________________________________________________________

CSS


@media all and (min-width: 768px){

  .main-content{
    flex-direction: row;
    overflow: hidden;

  }

  .thumbnail-list{
    flex-direction: column;
    margin-left: 20px;
    order: 0;

    }

    .thumbnail-item{
      max-width: 260px;

    }

    .thumbnail-item + .thumbnail-item{
      margin-top: 20px;

    }


  }

Add display:flex; 添加display:flex; at the top of class thumbnail-list in the css. 在CSS的类thumbnail-list的顶部。 This should solve the problem. 这应该可以解决问题。 At the moment you don't seem to be telling the css to use flexbox in the first place. 目前,您似乎并没有告诉CSS首先使用flexbox。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM