Why can’t I reverse aside my aside and Section:

Asked

Viewed 46 times

0

I’m trying to make the box2 get float:left and box1 with float:right but even setting the options HTML does not play what I need. This needs to happen without using grid or flexbox or anything other than basic css3 and html... I’m a beginner and need this foundation to continue learning responsiveness with legacy code...

@charset "utf-8";
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

main {
  width: 100vw;
}

.container {
  float: left;
  width: 100%;
  height: auto;
  padding: .5%;
  background-color: sienna;
}

.box1 {
  float: right;
  width: 100%;
  height: 200px;
  background-color: wheat;
}

.box2 {
  float: left;
  width: 100%;
  height: 200px;
  background-color: rgb(145, 247, 208);
}
<!DOCTYPE html>
<html lang="pt-br">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title> Teste 1 - Responsividade com media queries </title>
  <link rel="stylesheet" href="styleMobile_v1.css">
</head>

<body>
  <main>
    <div class="box-noticia">
      <div class="container">
        <div class="box1"></div>
        <div class="box2"></div>
      </div>

    </div>
  </main>
</body>

</html>

  • 1

    Could you reduce your code to a [example]? It’s easier to analyze only what went wrong than having to filter everything in your non-problem-related code.

  • Done Sorry I still can’t communicate right here...

2 answers

1

Puts box1 and box2 width at 50%, with 2 at 100% complicating :)

  • But I need one to stay under the other ^^

  • In this case, put the 2 in float right or left, and put width: 51%, if not the way you want, I think you’ll have to use flex or grid.

  • I got you guys. The solution was to make a separate query and "Divs" for each device where in html I set box1 and box2, in this order for desktop, and for mobile made box 2 and box 1, in this order, calling in CSS a query for each device and its respective resolutions. While one was active with "display: block" the other received "display: None".

0

You can do more than one way, using your code just enter the width from the boxes to 50%. Another option is to use the display: flex and the flex-flow:row. With the flex-flow, you can put the elements to answer as column if you want with flex-flow: column I left an example below.

@charset "utf-8";
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

main {
  width: 100vw;
}

.container {
  display: flex;
  flex-flow: row;
  width: 100%;
  height: auto;
  padding: .5%;
  background-color: sienna;
}

.box1 {
  width: 50%;
  height: 200px;
  background-color: wheat;
}

.box2 {
  width: 50%;
  height: 200px;
  background-color: rgb(145, 247, 208);
}
<!DOCTYPE html>
<html lang="pt-br">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title> Teste 1 - Responsividade com media queries </title>
  <link rel="stylesheet" href="styleMobile_v1.css">
</head>

<body>
  <main>
    <div class="box-noticia">
      <div class="container">
        <div class="box1"></div>
        <div class="box2"></div>
      </div>

    </div>
  </main>
</body>

</html>

  • Somehow I understood... But for now I can not use flexbox friend... I need to master use of floats and legacy codes...

  • Then just put the width for 50% of each div.

  • I need you to stay one under the other but in the reverse order... I’ve already got friend... obg by the attention ^^

Browser other questions tagged

You are not signed in. Login or sign up in order to post.