Z
Z
zencd2011-07-30 21:13:33
css
zencd, 2011-07-30 21:13:33

How to show something to the left of an element in CSS without shifting the element itself?

I tried this code. The last H1 element is shifted to the right, but I would like to see them all aligned.

jsfiddle.net/HQLfr/

<div id=container>
    <h1>one</h1>
    <h1>two</h1>
    <h1 class="special">three</h1>
</div>


#container {
    margin-left: 100px;
}

.special:before {
    content: '[x]';
    position: relative;
    left: -30px;
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
[
[email protected]><e, 2011-07-30
@zencd

#container {
    margin-left: 100px;
}

.special {
    position: relative;
}

.special:before {
    content: '[x]';
    position: absolute;
    left: -30px;
}

Z
Zamorozka, 2011-08-02
@Zamorozka

Why are you using three h1 tags? This is not ice at all, firstly you will not pass w3c validation, and secondly, Google does not index such sites.
By contract, one h1 element per page.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question