Find first element in div that has margin? (purpose: remove margin)


HOME ยป Web Design

I need to find the first (and last) element in a div that has a CSS margin set (> 0 px). (important: this is not necessarily the first or last element!)


Basically, I need to do this so that I can remove the margin-top for the first element and the margin-bottom for the last. Now I know you'll probably say "why not use "p:last" CSS syntax?"


Because the first or last element can be something else as well, it could be a list (UL, OL), an image, a paragraph, etc.. I cannot simply do, ul:last, ol:last, p:last as that could result in multiple elements being matched (one per type).


I only want to apply this to a single element. So that'


Related to : Find first element in div that has margin? (purpose: remove margin)
margin-top and margin-bottom inside floated div not working
Web Design

I have a problem with margin-top and margin-bottom for some elements inside a floated div.


It's a column div floated to the right (I have also 2 other column divs floated to the left)


Demo here:
http://jsfiddle.net/zTb3g/


I need the "float" to adjust columns in the page, but the margin-top and margin-bottom don't work in some of the elements (ex: b, label, a), yet it works normally for other elements (ex: p, input).


I tried a lot of clearing styles in different places of the markup. Hope someone can help.


Thanks


Find first element in div that has margin? (purpose: remove margin)
Web Design

I need to find the first (and last) element in a div that has a CSS margin set (> 0 px). (important: this is not necessarily the first or last element!)


Basically, I need to do this so that I can remove the margin-top for the first element and the margin-bottom for the last. Now I know you'll probably say "why not use "p:last" CSS syntax?"


Because the first or last element can be something else as well, it could be a list (UL, OL), an image, a paragraph, etc.. I cannot simply do, ul:last, ol:last, p:last as that could result in multiple elements being matched (one per type).


I only want to apply this to a single element. So that'

How can I make the bottom margin of a div equal to its percentage-calculated right margin?
Web Design

I have an array of floating divs that fit 4 to a row. Their widths and right margins add up to 100%. Their bottom margins, however, are static. CSS below:


.item {
position: relative;
float: left;
height: 200px;
width: 23%;
margin-right: 2%;
margin-bottom: 15px;
background-color: #ddd;
}

Is there a way to retrieve the value of the right margin and apply it to the bottom margin so they are always consistent?


Here is an example of what I have: http://jsfiddle.net/kVZMU/


Add margin left after second div and margin should get increase double
Web Design

Need to Add margin left after second div and margin should get doubled.


FOR EXAMPLE:
3rd li margin left - 220
4rd li margin left - 440
and so on.


<ul>
<li id="new-1">1</li>
<li id="new-2">2</li>
<li id="new-3">3</li>
<li id="new-4">4</li>
</ul>
$(function (){
var jn=220;
$('ul').find('li').each(function (){
jn += parseInt($(this).css('margin-right')) + 220;
alert(jn);
})
$('li').css("margin-right",jn)
})

When I add a margin to a nested DIV, it causes the parent DIV to receive the margin instead, unless I give the parent DIV a border. Why?
Web Design

Has anyone else ever ran across this? This is the second time it's come up in as many years and I am not sure the "correct" way to solve it.


I can achieve the same results with padding in the child, but it just makes no sense.


Testing in Safari/FF.


WPF: Why shouldn't I use {TemplateBinding Margin} in ControlTemplate - is Margin meant only for element's containers?
Web Design

I have created my own ControlTemplate for Button, like this:


<Style x:Key="LightButtonStyle" TargetType="{x:Type ButtonBase}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ButtonBase}">
<Border
x:Name="WrappingBorder"
Margin="{TemplateBinding Margin}"
...
>
<ContentPresenter
Content="{TemplateBinding Content}"
...
>

Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .