简体   繁体   中英

HTML5/CSS3 - Problems with margin-left

I'm with a problem here and I can't find what I'm doing wrong. I would like to understand why can't I apply "margin-left" on "Bruna Diniz" post, in the section I applied a class called "post__box" which has a "margin-left: 20px" attrib, I tried to override it with a "margin-left: 40px" class but it just don't work, if I apply this class in a div wrapping all it's child elements it don't work the same way, I mean, I wanna move the entire section to the left and not affect/reduce it's inner child elements size, you know?

Thanks for all the patience since now <3 -- and the comment/warning below, sorry about that (:

the images of what's happening:

Bruna Diniz(和其他职位)保证金问题

and finally my HTML5 (important parts !!!!) code:

    <!-- bruna diniz  -->
    <section class="posts__box posts__box--left -margin-left-40px">

      <div class="-margin-top-47px">

        <div class="box--text -font-left">
          <a class="--hover" href="revista\artistas\bruna-diniz.html">
            <p class="-font-black -font-source -font--text-big">corpo estrangeiro sem imagem<br>
             um espelho vazio que não sou capaz de ver e já não sei se um dia verei<br>
             se quer serei capaz de pintar algum rosto que imagino ser o meu<br>
             qualquer imagem que nos dissesse sobre aquele fio de navalha<br>
             pelo qual percorri e ainda percorrerei<br>
             imagine só o que serão nossos filhos<br>
             nossas filhas<br>
             que ainda não são frutos<br>
             e se forem algum, de quais flores irão nascer? (...)</p>
          </a>
        </div>

        <div class="box--author box--btn box--btn--black">
          <a class="--hover" href="revista\artistas\bruna-diniz.html">
            <h4 class="box--author--text author--white -font--small --hover--dimgray">Bruna Diniz</h4>
          </a>
        </div>

        <div class="box--continue box--btn box--btn--red">
          <a class="--hover" href="revista\artistas\bruna-diniz.html">
            <h5 class="box--continue--text continue--white -font--tiny --hover--dimgray">CONTINUAR A LEITURA</h5>
          </a>
        </div>

      </div>

    </section>

MY CSS3 code:

/* BLOCKS */

/* posts */

.box--btn {
  margin-top: 10px;
  border: 1.5px solid black;
  box-shadow: 2px 2px 2px dimgray;
}

.posts__box {
  margin-top: 40px;
  margin-left: 20px;
  width: 30%;
}

.box--title {
  text-align: center;
}

.box--img {
  width: 100%;
  box-shadow: 3px 3px 3px Dimgray;
}

.box--text {
  padding: 5px;
}

.box--author {
  float: right;
  width: 46%;
  height: 50px;
}

.box--author--text {
  margin-top: 10px;
  margin-left: 6px;
}

.box--continue {
  float: left;
  width: 46%;
  height: 50px;
}

.box--continue--text {
  margin-top: 12px;
  margin-left: 7px;
}

.posts__btns {
  float: left;
  margin-top: 20px;
  width: 100%;
  height: 200px;
}


/* MODIFIERS */

.revista__posts--height {
  height: 3000px;
}


/* posts */

.title--red {
  color: rgba(233, 26, 26, 1);
}

.title--size-small {
  font-size: 30px;
  text-shadow: 1.5px 1.5px black;
}

.title--size-large {
  font-size: 60px;
  text-shadow: 3px 3px black;
}

.box--btn--red {
  background: rgba(233, 26, 26, 1);
}

.continue--white {
  color: #ffffff;
  text-shadow: 1.5px 1.5px black;
}

.box--btn--black {
  background: #212121;
}

.author--white {
  color: #ffffff;
  text-shadow: 2px 2px black;
}

.posts__box--left {
  float: left;
}

.posts__box--right {
  float: right;
}

.posts__box--margin--fix--left {
  margin-top: 10px;
  margin-left: 40px;
}

.posts__box--margin--fix--top {
  margin-top: 34px;
  margin-left: 40px;
}

.posts__btns--left {
  float: left;
  margin-left: 20px;
}

.posts__btns--right {
  float: right;
  margin-right: 20px;
}

/* revista */

.revista__container--height {
  height: 4800px;
}

You have this class " -margin-left-40px " in your section but you haven't defined css for this class. Define it and I think it will work.

 -margin-left-40px {
     margin-left:40px !important;
  }

You haven't definied css for this class '-margin-left-40px'. Please add a following code in a css and i hope it will help you

 .-margin-left-40px {
     margin-left:40px;
  }

If its not overriding the css then you can use !important like in a below code:

.-margin-left-40px {
    margin-left:40px !important;
}

You should first add -margin-left-40px in your CSS, that might still not work as your making the third boxe float right and you're using this for every boxes.

.posts__box {
    margin-top: 40px;
    margin-left: 20px;
    width: 30%;
}

I will suggest you give the right floating box is margin like this

.posts__box__right {
    margin-top: 40px;
    margin-right: 20px;
    width: 30%;
 }

then apply the "-margin-left-40px" to bruna diniz as you did.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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