Pradyut Bhattacharya Pradyut Bhattacharya - 9 months ago 65
CSS Question

html sub list automatically adding padding

I m having a list which has a sub list, which I am populating with two DIVs, both FLOAT(ed) to the left.

The structure is like -

<ol> <li>
<div>first div</div>
<div>second div</div>

Now, the first floated left is a image which is doing fine, but the other left(with text shifted to the right) automatically adds a auto-padding of 7px at the top for which I have to do a padding-top on the first image div.

How do i remove the auto-padding in the second div?

The example here

I have marked out the problem in red in this image -
enter image description here

Answer Source

You can use negative margins, this will allow you to move the elements on any direction. In your case, you can add a negative margin-top to the second div.

.com_text {
    margin-top: -5px;