2017-07-29 96 views
2

我的Flexbox容器出現問題。我試圖尋找我的問題,但無法找到它是什麼。我的圖像溢出Flexbox容器

我的容器中的圖像很大,並溢出容器。

我試過使用.img { max-width:100% },width,align-content: flex-start但沒有任何工作。

有人可以告訴我我做錯了什麼嗎?

也非常感謝大家幫助我以前和這一次!

body { 
 
    background-color: #CCC; 
 
    color: black; 
 
    font-family: 'Raleway', sans-serif; 
 
    font-size: 1em; 
 
    display: flex; 
 
    flex-direction: column; 
 
    border-color: black; 
 
    border-style: solid; 
 
    border-width: 15px; 
 
    margin: 0; 
 
} 
 

 
.header { 
 
    align-items: center; 
 
} 
 

 
.logo { 
 
    display: flex; 
 
    font-size: 1.5em; 
 
    font-family: 'sans-serif'; 
 
    color: black; 
 
    text-decoration: none; 
 
    margin: 80px auto 15px 20%; 
 
} 
 

 
.nav-bar { 
 
    display: flex; 
 
    flex-wrap: wrap; 
 
    flex-direction: row; 
 
    margin: 0 auto; 
 
    justify-content: center; 
 
    width: 250px; 
 
    font-size: 1em; 
 
} 
 

 
li .col, 
 
.decor { 
 
    text-decoration: none; 
 
    color: white; 
 
    font-size: 1.2em; 
 
    padding: 10px; 
 
} 
 

 
.col { 
 
    list-style: none; 
 
} 
 

 
ul li a.selected, 
 
.decor:hover { 
 
    color: black; 
 
} 
 

 
.intro { 
 
    display: flex; 
 
    flex-wrap: wrap; 
 
    margin: 35px auto 0 20%; 
 
    max-width: 450px; 
 
    justify-content: flex-start; 
 
} 
 

 
#wrapper { 
 
    display: flex; 
 
    flex-wrap: wrap; 
 
    flex-direction: row; 
 
    margin: 10px auto; 
 
    justify-content: center; 
 
    background-color: green; 
 
    height: 500px; 
 
    max-width: 900px; 
 
} 
 

 

 
} 
 
#wrapper li { 
 
    padding: 5px; 
 
    background-color: red; 
 
}
<head> 
 
    <meta charset="utf-8"> 
 
    <title>Project of Martin Wong | HTML, CSS and Javascript</title> 
 
    <link href="css/normalize.css" rel="stylesheet"> 
 
    <link href="https://fonts.googleapis.com/css?family=Raleway" rel="stylesheet"> 
 
    <link href="css/main.css" rel="stylesheet"> 
 
    <link href="css/flexbox.css" rel="stylesheet"> 
 
</head> 
 

 
<body> 
 

 
    <!-- TOP HEADING LOGO AND NAV BAR--> 
 
    <header class="header"> 
 
    <a href="index.html" class="logo"> 
 
     <h1>Martin Wong</h1> 
 
    </a> 
 
    <ul class="nav-bar"> 
 
     <li class="col"> <a href="index.html" class="selected decor">Portfolio</a> </li> 
 
     <li class="col"> <a href="aboutme.html" class="decor">About me</a></li> 
 
     <li class="col"> <a href="contact.html" class="decor">Contact</a></li> 
 
    </ul> 
 
    </header> 
 
    <!------------------------------------------------------------------------> 
 

 
    <div class="intro"> 
 
    <h2>Training my skills for the future</h2> 
 
    <p>This is my journey to become a web developer. This website will tell my diary of my holiday that I went on in June</p> 
 
    </div> 
 

 

 

 

 

 
    <!--IMAGES IN THE MIDDLE----------------------> 
 
    <div class="wrapper"> 
 
    <section> 
 
     <ul id="wrapper"> 
 
     <li> 
 
      <a href="img/bro-and-me.jpg" class="container-image"> 
 
      <img src="img/bro-and-me.jpg" alt="brother&me" class="img"> 
 
      <p>A RARE half decent photo of me(right) and my brother(left) in Singapore. Photo taken by my father, And being ruined by mom walking into shot </p> 
 
      </a> 
 
     </li> 
 
     <li> 
 
      <a href="img/father.jpg" class="container-image"> 
 
      <img src="img/father.jpg" alt="father" class="img"> 
 
      <p>Father telling us a story while mom sniggers at a inside joke about our father</p> 
 
      </a> 
 
     </li> 
 
     <li> 
 
      <a href="img/mom.jpg" class="container-image"> 
 
      <img src="img/mom.jpg" alt="mom" class="img"> 
 
      <p>Mom feeling unwell on the journey to the big Buddha</p> 
 
      </a> 
 
     </li> 
 
     <li> 
 
      <a href="img/Park-plaza.jpg" class="container-image"> 
 
      <img src="img/Park-plaza.jpg" alt="parkplaza" class="img"> 
 
      <p>Park Plaza foodcourt. Cheap, delicious and quick-serving meals where I have many memories of</p> 
 
      </a> 
 
     </li> 
 
     </ul> 
 
    </section> 
 
    </div>

+0

加上'最小寬度:0'到Flex項目。 –

回答

-1

定義在div的柱網。它可能是有益的

如:

<div class="wrapper col-md-12"> 
//content 
</div> 
+0

這不提供問題的答案。一旦你有足夠的[聲譽](https://stackoverflow.com/help/whats-reputation),你將可以[對任何帖子發表評論](https://stackoverflow.com/help/privileges/comment);相反,[提供不需要提問者澄清的答案](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-c​​an- I-DO-代替)。 - [來自評論](/ review/low-quality-posts/16869411) – ewwink