Flexbox <p>элемент перекрывающегося изображения при изменении размера страницы - PullRequest
0 голосов
/ 23 января 2019

Когда я изменяю размер моей страницы, текст из моего правого столбца накладывается на изображение в левом столбце, например:

problem

Как мнеостановить это и заставить правильный столбец остаться там, где он есть, или перейти под изображение при изменении размера страницы?Я не хочу менять макет страницы, когда она полноэкранная, но я хочу, чтобы она была отзывчивой.

@import url(https://fonts.googleapis.com/css?family=Raleway);
body {
  margin: 0;
  font-family: 'Raleway', georgia, arial;
  background-color: #e0e0e0;
  text-align: center;
}

h1 {
  color: #aaaaaa;
  text-align: left;
}

.sortFilms {
  text-align: left;
  display: inline-block;
  background-color: #ff6699;
  width: 80%;
  padding: 20px;
}

header {
  text-align: center;
  display: inline-block;
  border-bottom: 5px;
  border-top: 0;
  border-left: 0;
  border-right: 0;
  border-style: solid;
  border-color: #aaaaaa;
  width: 80%;
  padding: 20px;
  background-color: #e0e0e0;
}

.newFilm {
  text-align: left;
  display: inline-block;
  background-color: #ff6699;
  width: 80%;
  padding: 20px;
}

label {
  font-size: 1em;
  padding: 6px;
  color: #fff;
  font-weight: 700;
  display: block;
  text-align: left;
}

.form {
  margin: auto;
  display: flex;
  text-align: center;
  flex-direction: column;
}

h2 {
  font-weight: 700;
  font-size: 2em;
  width: 50%;
  color: #B2365F;
}

#formTitle {
  margin-top: 0;
  margin-bottom: 0;
}

.row {
  margin-left: -20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.col {
  padding: 20px;
}

input,
textarea,
select {
  width: 100%;
  display: block;
  border-radius: 25px;
  background-color: #e0e0e0;
  padding: 10px;
  border: none;
  box-sizing: border-box;
}


}
.tagline {
  margin: 0;
  color: #333333;
  font-size: 1em;
  font-weight: 700;
}
input::placeholder {
  color: #000;
}
textarea::placeholder {
  color: #000;
}
#modifyFilmButton {
  float: right;
}
@media only screen and (max-width: 700px) {
  .row {
    grid-template-columns: 1fr;
  }
}
@media screen and (max-width:800px) {
  table {
    border: 0;
  }
  
  table caption {
    font-size: 1.3em;
  }
  
  table thead {
    border: none;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
  }
  
  table tr {
    border: 2px solid #e0e0e0;
    background-color: #e0e0e0;
    display: block;
    margin-bottom: .625em;
    border-radius: 20px;
  }
  
  table td {
    display: block;
    font-weight: bold;
    font-size: 1.2em;
    text-align: left;
    padding: 15px;
  }
  
  table td::before {
    /*
    * aria-label has no advantage, it won't be read inside a table
    content: attr(aria-label);
    */
    content: attr(data-label);
    float: left;
    font-weight: bold;
    text-transform: uppercase;
  }
  
  table td:last-child {
    border-bottom: 0;
  }
}
.oldFilm {
  border-bottom-left-radius: 20px;
  border-bottom-right-radius: 20px;
  text-align: left;
  display: inline-block;
  background-color: #AAAAAA;
  width: 80%;
  padding: 20px;
}
#oldTitle {
  margin-top: 0;
  margin-bottom: 0;
  color: #ff6699;
  padding-bottom: 20px;
}
td {
  padding: 5px;
  font-weight: bold;
}
table {
  border-collapse: collapse;
  text-align: center;
  width: 100%;
}
thead {
  background: #ff6699;
}
.reviewImage {
  width: 200px;
  border-radius: 20px;
}
.filmRow img {
  width: 300px;
  height: 420px;
  margin: 10px;
  border-radius: 20px;
}
.filmRow {
  -webkit-flex-flow: row wrap;
  justify-content: space-around;
}
#filmContainer {
  width: 100%;
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-around;
}
#date {
  padding: 5px;
  text-align: left;
  width: 30%;
}
#date input {
  width: auto;
}
#date label {
  display: -webkit-inline-box;
}
#oldTitle2 {
  margin-top: 0;
  margin-bottom: 0;
  color: #ff6699;
}
.genre {
  padding: 5px;
  text-align: left;
  width: 60%;
}
.genre input {
  width: auto;
}
.genre label {
  display: -webkit-inline-box;
}

/* third page */
#filmImage {
  width: 300px;
  height: 420px;
  margin: 10px;
  border-radius: 20px;
}
#filmTitle {
  font-weight: 700;
  margin-bottom: 20px;
  font-size: 3em;
  width: 100%;
  color: #B2365F;
}
#leftcol {
  width: 25%;
  display: flex;
  flex-direction: column;
}
#rightcol {
  display: flex;
  flex-direction: column;
  width: 50%;
  margin: 5px;
}
#rightcol label {
  padding: 0;
}
#rightcol p {
  margin-bottom: 10px;
  margin-top: 2px;
}
#filmContainer2 {
  width: 100%;
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
}
#indent {
  margin: 5px;
}
<header>
  <img src="img/rv-logo.png">
  <p class="tagline">Want to know whether or not it's worth paying to watch a certain film or not? See what we think first!</p>
</header>


<div class="sortFilms">
  <div id="filmContainer2">
    <div id="leftcol">
      <img id='filmImage' src="https://images-na.ssl-images-amazon.com/images/I/51Gh9OaWVcL.jpg">
    </div>
    <div id="rightcol">
      <p id='filmTitle'>Deadpool</p>
      <div id="indent">
        <label>Year:</label>
        <p id='filmYear'>2016</p>
        <label>Genre:</label>
        <p id='filmGenre'>Action/Comedy</p>
        <label>Rating:</label>
        <p id='filmRating'>9/10</p>
        <label>Synopsis:</label>
        <p id='filmSynopsis'>blah blah blah blah</p>
      </div>
      <a href='viewFilms.html'>Back to list</a>
    </div>
  </div>
</div>

1 Ответ

0 голосов
/ 23 января 2019

Проблема с вашим изображением: div, содержащий изображение, имеет ширину 25%, но ширина вашего изображения превышает 25% его родительского элемента, поэтому изображение переполняет его родительский.Вам не следует так делать, попробуйте установить ширину изображения на 100%.

Чтобы решить вашу проблему, установите ширину изображения на 100% и отрегулируйте ширину родительского элемента, чтобы настроить размер изображения

И еще один совет, если вы используете flexbox, используйте свойство flex-wrap: wrap ... чтобы div внутри flex автоматически смещался вниз в соответствии с размером экрана

Чтобы узнать больше о flex, проверьте этоссылка https://css -tricks.com / snippets / css / a-guide-to-flexbox /

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...