Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

HTML & CSS Creating responsive form with display: flex?

Vogtei

New Coder
Hey guys,

I just want to create a 2-column form but unfortunately it doesn't wrap among each other at the pixel width I set for mobile.
This is my code:
HTML:
<div class="formular-hintergrund">
          <div class="col-row-contact">
            <div class="col-row-upside">
                <!-- content -->
              </div>
                
            <div class="col-row-downside">
              <div class="col box-left">
                <!-- content -->
              </div>
                  <div class="col box-right">
                <!-- content -->
                  </div>
             </div>
              
            </div>
CSS:
.formular-hintergrund {
  width: 70%;
  height: 50%;
  margin: 0% 15%;
  background: #233DFF;
  border-radius: 20px;
  padding: 50px;

}

.box-left {
  margin-right: 15px;
  flex-direction: column;
}
.box-right {
  margin-left: 15px;
  flex-direction: column;
}

@media (max-width: 986px) {
  .formular-hintergrund {
    width: 95%;
    margin: 0% 2.5%;
    background: #233DFF;
  }
  .box-left {
    margin-right: 0px;
    margin-bottom: 15px;
  }
  .box-right {
    margin-left: 0px;
    margin-top: 15px;
  }
}

.col-row {
  width: 100%;
  display: flex;
}

.col-row-contact {
  width: 100%;
  display: block;
}

.col-row-upside {
  width: 100%;
  display: block;
}

.col-row-downside {
  width: 100%;
  display: flex;
}

.col {
  width: 100%;
}

@media (max-width: 986px) {
  .col-row {
    width: 100%;
    display: block;
  }

  .col {
    width: 100%;
  }
}

It basically looks like this on the desktop:
Bildschirmfoto-2021-10-17-um-20-20-39.png

On mobile, the right column should wrap unter the left.

Maybe some of you are having some ideas how to solve this.

Big thank you!!
Leon
 
Try to add this -
CSS:
.col-row-downside {
    width: 100%;
    display: flex;
    flex-direction: column;
}
First of all thank you for your help!

I created an @media with
CSS:
.col-row-downside {
    width: 100%;
    display: flex;
    flex-direction: column;
}

but boxes are now on every size among themselves. I tried then flex-direction:row without @media to get the boxes back besides on desktop size, but unfortunately it doesnt work :/
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom