Reputation: 4915
I am generating a bulleted list on a web site (by using a jquery auto-complete function) and am using responsive web design in the web site.
I want a space after each list item. I have added the following CSS to do so:
li
{
margin-bottom:20px;
}
However, when there is word wrap on a list item (say on mobile device), the total line spacing does not change.
I don't get proper spacing between the bottom of the word wrapped item and the next item.
The display looks like this:
How can I get the spacing to look like this:
I tried putting up a jsfiddle, but can't get the css for the jquery autocomplete (that works in my app) to work, let alone the css for the line spacing I added.
Here it is anyway, fyi:
Upvotes: 0
Views: 539
Reputation: 15686
Are you familiar with CSS specificity? http://coding.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know/
If your code is like the fiddle you posted, inspecting an li
item in the autocomplete will show you that the following attributes are being applied (coming from the jquery ui css file):
.ui-menu .ui-menu-item {
margin: 0;
padding: 0;
zoom: 1;
width: 100%;
}
This rule is more specific than your
li
{
margin-bottom:20px;
}
So, the actual bottom margin being applied is 0.
To fix this, you can do a margin-bottom: 20px !important;
(*not recommended), or use the same selector to overwrite the jquery ui (assuming your CSS is loaded after jquery ui css) like this:
.ui-menu .ui-menu-item {
margin-bottom: 20px;
}
Upvotes: 1