margin-right, no block moving



  • This design refuses to work:

    <style>
    .myblock{ 
    width:150px; 
    height:150px; 
    background-color:rgba(255,0,0,0.7); 
    margin-right:-150px; 
    }
    </style>
    <div class="myblock"></div>
    

    Yeah, you can use it. margin-leftbut he's doing a great job with all the, uh, signs and nos. What's my problem?



  • My opinion is why this is happening:

    1. Because the browser thinks to the right left about me.

    That's why. margin-left and works

    *{
      padding: 0;
      margin: 0;
    }
    .myblock {
      width: 150px;
      height: 150px;
      background-color: rgba(255, 0, 0, 0.7);  
      margin-left: 150px;   
    }
    <div class="myblock"></div>

    1. For margin-right it must be pressed to the right edge.

    * {
      padding: 0;
      margin: 0;
    }
    .myblock {
      width: 150px;
      height: 150px;
      background-color: rgba(255, 0, 0, 0.7);
      float: right;
      margin-right: 150px;
    }
    <div class="myblock"></div>


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2