Dividing div to 2 columns
I have seen some solutions to this problem but when I add inside the divs an angular2 component, it doesn't work.
Here is what I got so far:
Code:
<div id="container">
<div id="categoriesContainer">
<categories (onCategoryChanged)="categoryChanged($event)"></categories>
</div>
<div id="products-container">
<product-details *ngFor="let product of products$ | async" id="prodcut"
[product]="product"
[canAddProductToCart]="canAddToCart(product.$key) | async"
(onAddToCart)="addToCart($event)"></product-details>
<button md-button
*ngIf="!showCreateProductComponent"
id="create-product-button"
[disabled]="disableCreateProductButton$ |async"
(click)="showCreateProductComponent=true">
<i class="material-icons">add</i>
</button>
<create-product id="create-product"
(onCencel)="showCreateProductComponent=false"
(onCreateProduct)="onCreateProduct($event)"
*ngIf="showCreateProductComponent"></create-product>
</div>
<div style="clear: both"></div>
</div>
css:
//spliting the div to 2 columns
#container
border-style:solid;
border-width: 1px;
border-color: green;
padding: 10px;
margin: 10px
#categoriesContainer
width: 15%;
border-style: solid;
border-width: 1px;
border-color: blue;
float: left;
#products-container
border-style: solid;
border-width: 1px;
width: 85%;
border-color: red;
//for the angular2 compoennts
#prodcut
float: left;
margin-right: 10px;
margin-bottom: 10px;
#create-product
float: left;
margin-right: 10px;
margin-bottom: 10px;
#create-product-button
float: left;
margin-right: 10px;
margin-bottom: 10px;
Here is what I want: (the cards will be only in the red squer.)
Questions:
- How to fix this and why its working great when I remove the angular2 components and replace them with some simple html text?
Can I summerise this code without effecting anything:
<div id="categoriesContainer"
style="width: 15%;border-style: solid;border-width: 1px;border-color: blue;float: left">
<categories (onCategoryChanged)="categoryChanged($event)"></categories>
to:
<categories id="categoriesContainer"
style="width: 15%;border-style: solid;border-width: 1px;border-color: blue;float: left"
(onCategoryChanged)="categoryChanged($event)"></categories>
Thanks alot!
javascript css angular
add a comment |
I have seen some solutions to this problem but when I add inside the divs an angular2 component, it doesn't work.
Here is what I got so far:
Code:
<div id="container">
<div id="categoriesContainer">
<categories (onCategoryChanged)="categoryChanged($event)"></categories>
</div>
<div id="products-container">
<product-details *ngFor="let product of products$ | async" id="prodcut"
[product]="product"
[canAddProductToCart]="canAddToCart(product.$key) | async"
(onAddToCart)="addToCart($event)"></product-details>
<button md-button
*ngIf="!showCreateProductComponent"
id="create-product-button"
[disabled]="disableCreateProductButton$ |async"
(click)="showCreateProductComponent=true">
<i class="material-icons">add</i>
</button>
<create-product id="create-product"
(onCencel)="showCreateProductComponent=false"
(onCreateProduct)="onCreateProduct($event)"
*ngIf="showCreateProductComponent"></create-product>
</div>
<div style="clear: both"></div>
</div>
css:
//spliting the div to 2 columns
#container
border-style:solid;
border-width: 1px;
border-color: green;
padding: 10px;
margin: 10px
#categoriesContainer
width: 15%;
border-style: solid;
border-width: 1px;
border-color: blue;
float: left;
#products-container
border-style: solid;
border-width: 1px;
width: 85%;
border-color: red;
//for the angular2 compoennts
#prodcut
float: left;
margin-right: 10px;
margin-bottom: 10px;
#create-product
float: left;
margin-right: 10px;
margin-bottom: 10px;
#create-product-button
float: left;
margin-right: 10px;
margin-bottom: 10px;
Here is what I want: (the cards will be only in the red squer.)
Questions:
- How to fix this and why its working great when I remove the angular2 components and replace them with some simple html text?
Can I summerise this code without effecting anything:
<div id="categoriesContainer"
style="width: 15%;border-style: solid;border-width: 1px;border-color: blue;float: left">
<categories (onCategoryChanged)="categoryChanged($event)"></categories>
to:
<categories id="categoriesContainer"
style="width: 15%;border-style: solid;border-width: 1px;border-color: blue;float: left"
(onCategoryChanged)="categoryChanged($event)"></categories>
Thanks alot!
javascript css angular
add a comment |
I have seen some solutions to this problem but when I add inside the divs an angular2 component, it doesn't work.
Here is what I got so far:
Code:
<div id="container">
<div id="categoriesContainer">
<categories (onCategoryChanged)="categoryChanged($event)"></categories>
</div>
<div id="products-container">
<product-details *ngFor="let product of products$ | async" id="prodcut"
[product]="product"
[canAddProductToCart]="canAddToCart(product.$key) | async"
(onAddToCart)="addToCart($event)"></product-details>
<button md-button
*ngIf="!showCreateProductComponent"
id="create-product-button"
[disabled]="disableCreateProductButton$ |async"
(click)="showCreateProductComponent=true">
<i class="material-icons">add</i>
</button>
<create-product id="create-product"
(onCencel)="showCreateProductComponent=false"
(onCreateProduct)="onCreateProduct($event)"
*ngIf="showCreateProductComponent"></create-product>
</div>
<div style="clear: both"></div>
</div>
css:
//spliting the div to 2 columns
#container
border-style:solid;
border-width: 1px;
border-color: green;
padding: 10px;
margin: 10px
#categoriesContainer
width: 15%;
border-style: solid;
border-width: 1px;
border-color: blue;
float: left;
#products-container
border-style: solid;
border-width: 1px;
width: 85%;
border-color: red;
//for the angular2 compoennts
#prodcut
float: left;
margin-right: 10px;
margin-bottom: 10px;
#create-product
float: left;
margin-right: 10px;
margin-bottom: 10px;
#create-product-button
float: left;
margin-right: 10px;
margin-bottom: 10px;
Here is what I want: (the cards will be only in the red squer.)
Questions:
- How to fix this and why its working great when I remove the angular2 components and replace them with some simple html text?
Can I summerise this code without effecting anything:
<div id="categoriesContainer"
style="width: 15%;border-style: solid;border-width: 1px;border-color: blue;float: left">
<categories (onCategoryChanged)="categoryChanged($event)"></categories>
to:
<categories id="categoriesContainer"
style="width: 15%;border-style: solid;border-width: 1px;border-color: blue;float: left"
(onCategoryChanged)="categoryChanged($event)"></categories>
Thanks alot!
javascript css angular
I have seen some solutions to this problem but when I add inside the divs an angular2 component, it doesn't work.
Here is what I got so far:
Code:
<div id="container">
<div id="categoriesContainer">
<categories (onCategoryChanged)="categoryChanged($event)"></categories>
</div>
<div id="products-container">
<product-details *ngFor="let product of products$ | async" id="prodcut"
[product]="product"
[canAddProductToCart]="canAddToCart(product.$key) | async"
(onAddToCart)="addToCart($event)"></product-details>
<button md-button
*ngIf="!showCreateProductComponent"
id="create-product-button"
[disabled]="disableCreateProductButton$ |async"
(click)="showCreateProductComponent=true">
<i class="material-icons">add</i>
</button>
<create-product id="create-product"
(onCencel)="showCreateProductComponent=false"
(onCreateProduct)="onCreateProduct($event)"
*ngIf="showCreateProductComponent"></create-product>
</div>
<div style="clear: both"></div>
</div>
css:
//spliting the div to 2 columns
#container
border-style:solid;
border-width: 1px;
border-color: green;
padding: 10px;
margin: 10px
#categoriesContainer
width: 15%;
border-style: solid;
border-width: 1px;
border-color: blue;
float: left;
#products-container
border-style: solid;
border-width: 1px;
width: 85%;
border-color: red;
//for the angular2 compoennts
#prodcut
float: left;
margin-right: 10px;
margin-bottom: 10px;
#create-product
float: left;
margin-right: 10px;
margin-bottom: 10px;
#create-product-button
float: left;
margin-right: 10px;
margin-bottom: 10px;
Here is what I want: (the cards will be only in the red squer.)
Questions:
- How to fix this and why its working great when I remove the angular2 components and replace them with some simple html text?
Can I summerise this code without effecting anything:
<div id="categoriesContainer"
style="width: 15%;border-style: solid;border-width: 1px;border-color: blue;float: left">
<categories (onCategoryChanged)="categoryChanged($event)"></categories>
to:
<categories id="categoriesContainer"
style="width: 15%;border-style: solid;border-width: 1px;border-color: blue;float: left"
(onCategoryChanged)="categoryChanged($event)"></categories>
Thanks alot!
javascript css angular
javascript css angular
edited Nov 13 '18 at 5:10
Cœur
17.5k9104145
17.5k9104145
asked Oct 26 '16 at 7:45
Stav AlfiStav Alfi
3,98674084
3,98674084
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
Simple using flexbox
*box-sizing:border-box;
#wrapper
display: flex;
#left, #right
padding: 16px;
#left
width: 15%;
background: red;
#right
width: 85%;
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
Simple using float
s and box-sizing
You might want to use also a .clearfix
class here on the parent element
*box-sizing:border-box;
#left, #right
float: left;
padding: 16px;
#left
width: 15%;
background: red;
#right
width: 85%;
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
Using display:table
(cross-browser)
#wrapper
display: table;
width: 100%;
border-collapse: collapse;
#left, #right
display: table-cell;
padding: 16px;
#left
width: 15%;
background: red;
#right
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
add a comment |
Have you tried float:left
for children node and clear:both, content: ''
for the parent node?
What I mean is that you miss a float:left
for the #products-container
<div class="container clearfix">
<div id="categoriesContainer" style="float:left" ></div>
<div id="products-container" style="float:left" ></div>
</div>
About the clearfix class, you can refer to Bootstrap here.
Math bro, math. 15% + 85% + paddings + borders != 100%
– Roko C. Buljan
Oct 26 '16 at 7:52
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f40256495%2fdividing-div-to-2-columns%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Simple using flexbox
*box-sizing:border-box;
#wrapper
display: flex;
#left, #right
padding: 16px;
#left
width: 15%;
background: red;
#right
width: 85%;
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
Simple using float
s and box-sizing
You might want to use also a .clearfix
class here on the parent element
*box-sizing:border-box;
#left, #right
float: left;
padding: 16px;
#left
width: 15%;
background: red;
#right
width: 85%;
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
Using display:table
(cross-browser)
#wrapper
display: table;
width: 100%;
border-collapse: collapse;
#left, #right
display: table-cell;
padding: 16px;
#left
width: 15%;
background: red;
#right
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
add a comment |
Simple using flexbox
*box-sizing:border-box;
#wrapper
display: flex;
#left, #right
padding: 16px;
#left
width: 15%;
background: red;
#right
width: 85%;
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
Simple using float
s and box-sizing
You might want to use also a .clearfix
class here on the parent element
*box-sizing:border-box;
#left, #right
float: left;
padding: 16px;
#left
width: 15%;
background: red;
#right
width: 85%;
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
Using display:table
(cross-browser)
#wrapper
display: table;
width: 100%;
border-collapse: collapse;
#left, #right
display: table-cell;
padding: 16px;
#left
width: 15%;
background: red;
#right
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
add a comment |
Simple using flexbox
*box-sizing:border-box;
#wrapper
display: flex;
#left, #right
padding: 16px;
#left
width: 15%;
background: red;
#right
width: 85%;
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
Simple using float
s and box-sizing
You might want to use also a .clearfix
class here on the parent element
*box-sizing:border-box;
#left, #right
float: left;
padding: 16px;
#left
width: 15%;
background: red;
#right
width: 85%;
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
Using display:table
(cross-browser)
#wrapper
display: table;
width: 100%;
border-collapse: collapse;
#left, #right
display: table-cell;
padding: 16px;
#left
width: 15%;
background: red;
#right
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
Simple using flexbox
*box-sizing:border-box;
#wrapper
display: flex;
#left, #right
padding: 16px;
#left
width: 15%;
background: red;
#right
width: 85%;
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
Simple using float
s and box-sizing
You might want to use also a .clearfix
class here on the parent element
*box-sizing:border-box;
#left, #right
float: left;
padding: 16px;
#left
width: 15%;
background: red;
#right
width: 85%;
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
Using display:table
(cross-browser)
#wrapper
display: table;
width: 100%;
border-collapse: collapse;
#left, #right
display: table-cell;
padding: 16px;
#left
width: 15%;
background: red;
#right
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
*box-sizing:border-box;
#wrapper
display: flex;
#left, #right
padding: 16px;
#left
width: 15%;
background: red;
#right
width: 85%;
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
*box-sizing:border-box;
#wrapper
display: flex;
#left, #right
padding: 16px;
#left
width: 15%;
background: red;
#right
width: 85%;
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
*box-sizing:border-box;
#left, #right
float: left;
padding: 16px;
#left
width: 15%;
background: red;
#right
width: 85%;
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
*box-sizing:border-box;
#left, #right
float: left;
padding: 16px;
#left
width: 15%;
background: red;
#right
width: 85%;
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
#wrapper
display: table;
width: 100%;
border-collapse: collapse;
#left, #right
display: table-cell;
padding: 16px;
#left
width: 15%;
background: red;
#right
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
#wrapper
display: table;
width: 100%;
border-collapse: collapse;
#left, #right
display: table-cell;
padding: 16px;
#left
width: 15%;
background: red;
#right
background: blue;
<div id="wrapper">
<div id="left">left</div>
<div id="right">right</div>
</div>
edited Oct 26 '16 at 8:23
answered Oct 26 '16 at 8:04
Roko C. BuljanRoko C. Buljan
125k21188224
125k21188224
add a comment |
add a comment |
Have you tried float:left
for children node and clear:both, content: ''
for the parent node?
What I mean is that you miss a float:left
for the #products-container
<div class="container clearfix">
<div id="categoriesContainer" style="float:left" ></div>
<div id="products-container" style="float:left" ></div>
</div>
About the clearfix class, you can refer to Bootstrap here.
Math bro, math. 15% + 85% + paddings + borders != 100%
– Roko C. Buljan
Oct 26 '16 at 7:52
add a comment |
Have you tried float:left
for children node and clear:both, content: ''
for the parent node?
What I mean is that you miss a float:left
for the #products-container
<div class="container clearfix">
<div id="categoriesContainer" style="float:left" ></div>
<div id="products-container" style="float:left" ></div>
</div>
About the clearfix class, you can refer to Bootstrap here.
Math bro, math. 15% + 85% + paddings + borders != 100%
– Roko C. Buljan
Oct 26 '16 at 7:52
add a comment |
Have you tried float:left
for children node and clear:both, content: ''
for the parent node?
What I mean is that you miss a float:left
for the #products-container
<div class="container clearfix">
<div id="categoriesContainer" style="float:left" ></div>
<div id="products-container" style="float:left" ></div>
</div>
About the clearfix class, you can refer to Bootstrap here.
Have you tried float:left
for children node and clear:both, content: ''
for the parent node?
What I mean is that you miss a float:left
for the #products-container
<div class="container clearfix">
<div id="categoriesContainer" style="float:left" ></div>
<div id="products-container" style="float:left" ></div>
</div>
About the clearfix class, you can refer to Bootstrap here.
edited Oct 26 '16 at 7:56
answered Oct 26 '16 at 7:51
Gabriel CheungGabriel Cheung
30226
30226
Math bro, math. 15% + 85% + paddings + borders != 100%
– Roko C. Buljan
Oct 26 '16 at 7:52
add a comment |
Math bro, math. 15% + 85% + paddings + borders != 100%
– Roko C. Buljan
Oct 26 '16 at 7:52
Math bro, math. 15% + 85% + paddings + borders != 100%
– Roko C. Buljan
Oct 26 '16 at 7:52
Math bro, math. 15% + 85% + paddings + borders != 100%
– Roko C. Buljan
Oct 26 '16 at 7:52
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f40256495%2fdividing-div-to-2-columns%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown