Why is margin-right not working in ionic + AngularJS? - css

I have a scrolling content div, whose content I want to give some margin-left as well as from right. It is taking margin-left, but not taking margin right. I set margin in %.
<ion-scroll scrollbar-y="true" delegate-handle="invoicegrid" ng-style="viewHeight">
<div style="margin-left:5%; margin-right:5%" class="row brd"" ng-repeat="column in invoice_records track by $index" ng-class-odd="" ng-class="{white:$index%2 == 0,blue:$index%2 == 1}">
<div class="col brdlrdt collapse-sm" ng-repeat="field in column.columns" ng-show="invoice_column_name[$index].checked && invoice_column_name[$index].fieldNameOrPath===field.fieldNameOrPath">{{field.value}}</div>
<div class="col col-10 text-center brdlrdt collapse-sm"></div>
</div>
</ion-scroll>
Plunkr example.
How can I get it to detect my margin-right setting?

The css in ionic.css sets elements with the class "row" to a width of 100%. When you add margins, the width of your row becomes 100% + 5% + 5%, and the row is wider than its container.
There are several ways to fix this.
You can remove width: 100%
You can add padding to the parent div (instead of margins on the rows)
Changing the position type

If someone still have this problem with Ionic, the solution for me was to not put my content inside the div with class="row".

Related

HTML: Div is not in align?

Hello i used Bootstrap and my 2 div col-md-6 and col-md-6 are not in align in height.
Use this css for the first div.
div.col-md-6 {
display: inline-block;
vertical-align:middle;
}
The simplest way to align vertical align here is to add padding from top in the first div.Your second div have buttons and must be having padding also.
Use min-height for both using class to div. It will solve your query.
eg:
<div class="col-md-6 mycol">
</div>
<div class="col-md-6 mycol">
</div>
style.css
.mycol{
min-height:100px;
}
Without the code, it's hard to find the cause, but I guess your two div are without a css height property and then adapt to their content.
The div on the right contains items that seems to have a padding on top and bottom, resulting in an item with a greatest height than the one on the left.
Your two div are aligned on the top and as it's already been mentionned you need to add the same padding on the left and right cols (I don't like the vertical align answer, as it work in this case, but could cause issues as the cols height could change).
If you dont have a scenario where you text will wrap to the next line, you can use line-height which will be same for both the sections.

extend div beyond bootstraps container

I have a set up in wordpress using bootstrap what follows:
<div class="container">
<div class="row">
<div id="NEEDS TO BE FULL WIDTH>
</div>
</div>
</div>
I would like the background of the "NEEDS TO BE FULL WIDTH" div be full browser width but not sure how. If I make it more the 100% width it makes a horizontal scroll. Any ideas?
You can have multiple .container elements inside your html. If you change the .container into a container-fluid the content of the container will take up 100%
If you only want the background to be full width, but you want the content to be constrained by the .container (at most about 1140 pixels wide) then surround the .container with another <div> and put the background-image on that element.

Fill div with position absolute - auto width

Im trying to make a div fill out the correct amount, corresponding to the text within it. This is normal behaviour with divs, but when adding position:relative and absolute theres trouble.
<div style="position:relative;background-color:#CDCDCD;">
<div style="position:absolute;top:0px;left:0px;">sadasd</div>
</div>
Its simple, i just want the background color to fill as long as the text goes. Setting a width is not an option.
I've tried with width:auto and display:block but I cant get it to work.
<div style="position:relative;">
<div style="position:absolute;top:0px;left:0px;background-color:#CDCDCD;">sadasd</div>
</div>
Just move the background-color to the inner div, that will do the job!

div x inside mutilple divs cant expand its height specified in %?

i have a sidebar having many nested divs to place my rounded corrners.but when i tried to set the content's div height equal to 90% its not expanding.what is the issue.my html,body have 100% height.my div nest is some what like this.
<body>
<div class="main"> //it contains header n content div,its height is 90%
<div class="header"></div> //its height is 10% of main div
<div class="content"> //its height is 90% of main div
<div class="vertical_navigation"> //its height is 99% of content div
<div><div><div><div> //thses divs are for rounded corner image concept
<div> </div> //this div contains the data.now its height is 80% but its not expanding?h
//i cant use min-height,its not working too.how to give height referenced to //vertical navi div??
</div></div></div></div>
</div>
</div>
</div>
<footer></footer>
</body>
have you considered applying rounded corners with just css and not worrying about the ieretards not having them?
When having so much nested div, it's good you consider the measurement in width and height of the DIV if the container div is lesser that the ones inside it, it won't stretch,because that way, the browser can't detect how far the div is meant to stretch. to resolve this use make proper use of CSS.

Help needed with DIV-layout for site

I am trying to build a page with the following in it:
Already have the following:
one div for page to center the whole page with width 809px
inside <div class="page"> is the following:
<div class="header">
<div class="container"> (container for content stuff)
<div class="footer">
What I am struggling with:
<div class="container"> should contain the following:
leftmost <div class="leftShadow"> with 100% height to container, with left shadow image as background for <div class="leftShadow">
second to left <div class="custom_content"> with 100% height to container (will contain content of page
second to right <div class="sidebar_right"> with 100% height to container (will contain extra links)
rightmost <div class="rightShadow"> with 100% height to container, with right shadow image as background for <div class="rightShadow">
So to summarise:
<div class="page">
<div class="header">header image</div>
<div class="container">
<div class="leftShadow"><img src="images/spacer.gif" alt="" /></div>
<div class="custom_content">(this is where the content would be)</div>
<div class="sidebar_right">(some other links)</div>
<div class="rightShadow"><img src="images/spacer.gif" alt="" /></div>
</div>
So what is supposed to happen is, when either custom_content or sidebar_right div's strength in length below the other, the other one would stretch in height to be the same with as the longer div. Obviously, both side div's (leftShadow and rightShadow) should also stretch to 100% of the container's height.
Can someone please guide me in the right direction? Basically, these div's should behave much like a table would when one td's content stretches beyond the height of the other td's.
Don't use divs like tables!
The leftShadow and rightShadow divs are completely unnecessary. Combine your background images into a single image and set it as the background of your container div.
To make sure the background image fills the height of the container, set background-repeat: repeat-y.
Why not use something like "Faux Columns"?
See http://www.alistapart.com/articles/fauxcolumns/
Perhaps you won't need the leftShadow and rightShadow divs: take a look at faux columns.
This is what you are looking for, I hope. :)
I'd do this differently because you're not going to get your divs to behave like tables.
I'm not entirely sure what you're wanting this to look like, but I'm guess you want some sort of shadow image down the left and right side of the container div. How about removing the leftShadow and rightShadow divs, put a repeatable background image on the content div of width 809px (and maybe height 1, depending on what your shadow image looks like). Also perhaps set overflow:hidden on the content div - if I remember rightly thats a kind of hack which will make the containing div stretch in this situation.

Resources