0

The direction of the body is rtl. I want the button-div div to stick to the left side of it's parent div, but It doesn't. Why is that?

#header-row {
  display: flex;
  margin: 0px 100px 0px 100px;
}

#button-div {
  float: left;
}
<!DOCTYPE html>

<head>
  <link rel="stylesheet" href="header.css">
</head>

<body dir="rtl">
  <div id="header-row">

    <div id="button-div">
      <div>
        <button id="login-button">ورود</button>
        <button id="register-button">ثبت نام</button>
      </div>
      <button id="market-button">ورود به فروشگاه</button>
    </div>
  </div>
</body>
Temani Afif
  • 245,468
  • 26
  • 309
  • 415
negar.n
  • 43
  • 8

3 Answers3

1

That's because float and clear are not supported for flex items. Your options are either to set correct justify-content, or if all items are, let's say, rightly aligned, then to align it to left you could do: margin-right: auto

benNek
  • 58
  • 1
  • 7
1

The problem is that float is not supported in flex items. check this out and let me know if it works perfectly.

   #header-row {
       display: flex;
       margin: 0px 100px 0px 10px;
   }

   .button-div {
       float: left;
   }
<!DOCTYPE html>
   <head>
   <link rel="stylesheet" href="header.css">
   </head>
   <body dir="rtl">
       <div id="header-row" class="button-div">
    
               <div >
                   <button id="login-button">ورود</button>
                   <button id="register-button">ثبت نام</button>
               </div>
               <button id="market-button">ورود به فروشگاه</button>
        </div>
   </body>
0

float property is ignored with flex, so can either remove flex or if you want to use flex, then pass flex-direction

  • Solution 1.

<html>

<head>
  <style>
    #header-row {
      margin: 0px 100px 0px 100px;
    }
    
    #button-div {
      float: left;
    }
  </style>
</head>

<body dir="rtl">
  <div id="header-row">

    <div id="button-div">
      <div>
        <button id="login-button">ورود</button>
        <button id="register-button">ثبت نام</button>
      </div>
      <button id="market-button">ورود به فروشگاه</button>
    </div>
  </div>
</body>

</html>
  • solution 2.

<html>

<head>
  <style>
    #header-row {
      display: flex;
      margin: 0px 100px 0px 100px;
      flex-direction: row-reverse;
    }
    
    #button-div {}
  </style>
</head>

<body dir="rtl">
  <div id="header-row">

    <div id="button-div">
      <div>
        <button id="login-button">ورود</button>
        <button id="register-button">ثبت نام</button>
      </div>
      <button id="market-button">ورود به فروشگاه</button>
    </div>
  </div>
</body>

</html>
G-Cyrillus
  • 101,410
  • 14
  • 105
  • 129