Reputation: 67
I have been trying my hand at Electron and for that, I am trying to create 2 divs, next to each other. I have read a few solutions on here for aligning 2 divs next to each other, but nothing works for me. Here's my code so far:
Code
body, html {
height: 100%;
}
.wrapper{
height: 90%;
}
.request-pane {
float:left; /* add this */
margin-left: 10%;
height: 90%;
width: 45%;
border: 1px solid red;
}
.response-pane {
float:right; /* add this */
margin-left: 55%;
height: 90%;
width: 45%;
border: 1px solid black;
}
<div class="wrapper">
<div class="request-pane"></div>
<div class="response-pane"></div>
</div>
Can anyone point me out what I'm doing wrong here? I am very new to HTML, so I don't know if the solution is too obvious or not
Upvotes: 1
Views: 56
Reputation: 460
If you want even more simpler way, use bootstrap. Divide your screen into two halves. In each section create div. This will full fill your requirements.w3school is best website for this.
Upvotes: 0
Reputation: 354
Remove the margin-left
property and also add display:inline-flex
to the css class request-pane
and response-pane
as shown below.
body, html {
height: 100%;
}
.wrapper{
height: 90%;
}
.request-pane {
float:left; /* add this */
height: 90%;
width: 45%;
border: 1px solid red;
display:inline-flex;
}
.response-pane {
float:right; /* add this */
height: 90%;
width: 45%;
border: 1px solid black;
display:inline-flex;
}
<div class="wrapper">
<div class="request-pane"></div>
<div class="response-pane"></div>
</div>
This works fine. Do run the code from snippet,I hope that's the result you wanted.
Upvotes: 1
Reputation: 2397
you can do it by two ways.
remove float atrribute and add
.wrapper{ height: 90%; display: flex; }
try using display:inline-block in css for both request-pane and response-pane
Upvotes: 2
Reputation: 3137
If you want to keep floats
here - fixed with code
body, html {
height: 100%;
}
.request-pane, .response-pane {
box-sizing: border-box; /* count border inside of a `width` */
}
.wrapper {
height: 90%;
}
.request-pane {
float: left;
margin-left: 10%;
height: 90%;
width: 45%;
border: 1px solid red;
}
.response-pane {
float: right;
/* margin-left: 55%; */ /* this is a root of a problems */
height: 90%;
width: 45%;
border: 1px solid black;
}
<div class="wrapper">
<div class="request-pane"></div>
<div class="response-pane"></div>
</div>
But yes, you probably better to go with flexbox. A good guide to it you can find here: https://css-tricks.com/snippets/css/a-guide-to-flexbox/.
Also, it looks like you lack a basic understanding of how HTML/CSS work, so you'd better have some basics free courses to moving forward.
Upvotes: 1