简体   繁体   English

HTML5 / CSS3-左边距有问题

[英]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? 我想了解为什么我不能在“ Bruna Diniz”帖子上应用“ margin-left”,在本节中我应用了一个名为“ post__box”的类,该类具有“ margin-left:20px”属性,我尝试覆盖它带有一个“ margin-left:40px”类,但它只是行不通,如果我在将所有子元素都包含在其中的div中应用该类,它就不会以相同的方式起作用,我的意思是,我想移动整个部分向左移动并不会影响/减小其内部子元素的大小,您知道吗?

Thanks for all the patience since now <3 -- and the comment/warning below, sorry about that (: 感谢您自<3以来的所有耐心,以及下面的评论/警告,对此表示抱歉(:

the images of what's happening: 正在发生的图像:

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

and finally my HTML5 (important parts !!!!) code: 最后是我的HTML5(重要部分!!!!)代码:

    <!-- 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: 我的CSS3代码:

/* 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. 您的部分中有此类“ -margin-left-40px ”,但尚未为此类定义css。 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'. 您尚未为此类“ -margin-left-40px”定义css。 Please add a following code in a css and i hope it will help you 请在CSS中添加以下代码,希望对您有所帮助

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

If its not overriding the css then you can use !important like in a below code: 如果它没有覆盖CSS,那么您可以像下面的代码中那样使用!important:

.-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. 您应该首先在CSS中添加-margin-left-40px ,这可能仍然无法正常工作,因为您使第三个框向右浮动,并且每个框都使用此框。

.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. 然后像您一样对bruna diniz应用“ -margin-left-40px”

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

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