tags:

views:

102

answers:

3

I'm currently reimplementing corporate style for our documentation (HTML + CSS + PrinceXML = PDF) and can't quite fix one thing. What I need are handing section numbers, i.e. headers themselves are left-aligned vertically with the text but section numbers are "hanging" in the left column. Probably the best example to illustrate this is browser's rendering of numbered lists:


  1. Heading 1

    Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

  2. Heading 2

    Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.


Essentially, I want to implement the same for headings, for all levels. Is there any sane way to do this in CSS?

A: 

Try this:

h1, h2, h3 {
  text-align: left;
  margin-left: -10px;
}
Zack
+1  A: 

I've got this done. Essentially, every counter has to be floated to the left:

h1:before {
    content: counter(chapter) ". ";
    float:left;
    width: 1.2cm;
}

and every heading has to get a margin and a left attribute:

h1 {    
    left: 1.2cm;
    margin-left: -1.2cm;
}
rassie
A: 

h1 { margin-left: -10px; } will work until your header goes to two lines.

How about this:

h1 { text-indent: -10px }

Eric Meyer