Add padding to a single div - html

How can I add padding to the top of a single div? Is there a way to do it without modifying the .css file? I am using Bootstrap and there is no space between the carousel and the first div. I tried adding padding to the carousel, but the color of the left and right chevron overlap the padding, and this is not the look I want. I want a true white space between the two.

Try <div style="padding-top: 10px;"> :)

Use firebug on Chrome or Firefox and see which div or element inside the carousel needs the padding you want.
However, the best way would be to use CSS. As you said, you want a padding, and CSS has the padding property. As #Jorgen said, just add a padding top.
Otherwise use <br> instead as #Mr Lister said

Related

How to color footer margins?

Well , I have a site with margins and a footer with different background color.
The problem is that the footer margins do not get colored in the same color as the specified footer color.
The Html code -
Here I would like color the green space orange.
I have tried replacing the margin with padding , but it does not work .
Now the problem has been resolved. Do not answer.
Usepadding css property on footer instead of margin.
Margin, as such, doesn't have background color. Margin is invisible border, a space between two objects.
Refer this Stack Overflow answer to understand more.
Hard to tell without seeing the code but I'm assuming that if changing the margin to padding for your footer div didn't work then that element might be nested inside of the element with the margin that you're saying you're applying for the site. Move the footer DIV outside of that element and apply the padding to it, not sure though without seeing the code so I could be off on that
You should use padding instead of margin in such case..

How to set margin to the responsive template without ruining it?

I'm using downloaded bootstrap template for my Web Application.It had the side-bar menu I deleted it thought irrelevant.Now I have to add the left margin for the body of template.When adding left-margin it collapsed. How to add left margin without ruining it.
Please suggest.
Why don't you put a place holder <div> where the sidebar used to be. Make sure it has the same width, height, padding, margin, position, and float properties as the sidebar then set visiblity: hidden;. That way no collapse.
Note that <div> should be empty or do this: <div> </div>.

HTML 5 move Text like Margin but without Margin

How can I move text in HTML 5 like margin but without using margin because
two texts on my page repel each other with margin
You can either add padding, like indubitablee said.
Or you can create another div and wrap it around what you want, then add a margin to that.
try using padding http://www.w3schools.com/css/css_padding.asp
padding is generally creating space within an element whereas margin is creating space outside of an element. hope this helps

Padding/Margin/Border On Element Does Not Change DIV Height

Here is a very simply jsFiddle to demonstrate my problem: http://jsfiddle.net/ryandlf/mSmUv/4/
When an element has a top padding or margin and it sits on the first line within a div, the div does not respect that padding or margin and push the element down. In most cases this isn't an issue, but for example, if I have a button that has a top border and padding the top of the border will be cut off because the div is not taking into consideration the padding value.
Is there a workaround for this other than just blindly setting margins or padding on every container div element and hoping I have added enough to account for any internal element that might be affected?
your link with class button is not a block element, it is inline element. Change this default behaviour by adding dispaly: block to it and it will work as expected. Proof available on jsfiddle.
So to sum up, the problem is not with the div - it is the problem with css - inline elements ignore margin and padding because they cannot 'reserve space'.
UPDATE: To answer your comment, here is the solution you might be looking for
The button element is inline. To get the desired behavior you can set display:inline-block.
Check here
Try to add following to the parent div:
overflow: hidden
I hope it helps!

Text wraps around floating div but borders and <hr />s do not

I have a div that is float: right and it is inside a parent div. There are p elements inside that same parent div also, and the text wraps around the float: right div properly.
However, if I set the p elements to have a border, or do a <hr />, the border does not stop where the text stops, but extends behind the float: right div.
Here is a beautiful mspaint depiction of the situation:
Note that the green part of the black horizontal line is behind the floating div.
How do I get the border or <hr /> or whatever to be only as wide as the text, and not go behind the div?
I know this problem was posted some time ago, but I had the same problem today and found another solution:
http://jsfiddle.net/MvX62/
I use border-bottom instead of the <hr /> tag and had to add an overflow: hidden;. Look at the fiddle, i think this is more useful then the accepted solution, because you can also add a margin to the horizontal line and there is the same gap, as the text has.
Also you don't need to define z values and don't need any hacks or workarounds.
I've had this problem before, and I wasn't sure if it was solvable.
In your case, however, you could wrap the green box with another element and swap margin with padding and set its background to #fff to cover the offending line.
Check out the fiddle...
http://jsfiddle.net/UnsungHero97/8BwGB/3/
What I did here was give the floated element a z-index CSS property, which will put it "above" the non floated element (which has a smaller valued z-index) and the <hr /> will not go above the floated element.
In regards to getting it as wide as the text, in my example it is as wide as the text, but I'm not sure if that holds across browsers (I'm on Chrome). Let me know if it doesn't.
I hope this helps.
Hristo
p.s. excellent mspaint skillz :)
You would have to set the width of the paragraphs to the width of the container minus the width of the floating element, or you could give them a margin on the same side of the float equal to the float's width.
Div cannot wrap around another div. Wrapping is text-only property. You can simulate wrapping by setting the margin-right for the master div to the width of the div you want it to wrap, but text wil not flow under the inset div.
Some values of the overflow property can cause this behavior. Specifically, overflow: visible which is often set by popular CSS resets/normalization.