Note that there are some explanatory texts on larger screens.

plurals
  1. POHtml/CSS aligning the text of a label
    text
    copied!<p>I try to use html+CSS to present a directory tree structure. What I am missing is how to align the size and data of each file in specific horizontal positions.</p> <p>This might be cleared of you take a look at the code below. At the 10th line there is "File1 8MB 01/12/2010". How can I align "8MB" to the center and "01/12/2010" to the right side? </p> <p>After the html I attach the CSS in case it helps. I am new at this so thanks for your help and patience.</p> <pre><code>&lt;body&gt; &lt;div&gt; Size Date &lt;/div&gt; &lt;ol class="tree"&gt; &lt;li&gt; &lt;label for="folder1"&gt;Folder1&lt;/label&gt; &lt;input type="checkbox" checked disabled id="folder1" /&gt; &lt;ol&gt; &lt;li class="file"&gt;File1 8MB 01/12/2010&lt;/li&gt; &lt;li&gt; &lt;label for="subfolder1"&gt;Subfolder 1&lt;/label&gt; &lt;input type="checkbox" id="subfolder1" /&gt; &lt;ol&gt; &lt;li class="file"&gt;File1 8MB 01/12/2010&lt;/li&gt; &lt;li&gt; &lt;label for="subsubfolder1"&gt;Subfolder1&lt;/label&gt; &lt;input type="checkbox" id="subsubfolder1" /&gt; &lt;ol&gt; &lt;li class="file"&gt;File2 8MB 01/12/2010&lt;/a&gt;&lt;/li&gt; &lt;li&gt; &lt;label for="subsubfolder2"&gt;Subfolder 1&lt;/label&gt; &lt;input type="checkbox" id="subsubfolder2" /&gt; &lt;ol&gt; &lt;li class="file"&gt;Subfile1 8MB 01/12/2010&lt;/li&gt; &lt;li class="file"&gt;Subfile2 8MB 01/12/2010&lt;/li&gt; &lt;/ol&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/li&gt; &lt;li class="file"&gt;File3 8MB 01/12/2010&lt;/li&gt; &lt;li class="file"&gt;File4 8MB 01/12/2010&lt;/li&gt; &lt;/ol&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/li&gt; &lt;/ol&gt; &lt;/body&gt; </code></pre> <p>Here is the CSS in case it helps:</p> <pre><code>/* Just some base styles not needed for example to function */ *, html { font-family: Verdana, Arial, Helvetica, sans-serif; } body, form, ul, li, p, h1, h2, h3, h4, h5 { margin: 0; padding: 0; } body { background-color: #606061; color: #ffffff; margin: 0; } img { border: none; } p { font-size: 1em; margin: 0 0 1em 0; white-space: pre } div{white-space: pre-wrap;} html { font-size: 100%; /* IE hack */ } body { font-size: 1em; /* Sets base font size to 16px */ } table { font-size: 100%; /* IE hack */ } input, select, textarea, th, td { font-size: 1em; } /* CSS Tree menu styles */ ol.tree { padding: 0 0 0 30px; width: 900px; } li { position: relative; margin-left: -15px; list-style: none; } li.file { margin-left: -1px !important; } li.file a { background: url(document.png) 0 0 no-repeat; color: #fff; padding-left: 21px; text-decoration: none; display: block; } li input { position: absolute; left: 0; margin-left: 0; opacity: 0; z-index: 2; cursor: pointer; height: 1em; width: 1em; top: 0; } li input + ol { background: url(toggle-small-expand.png) 40px 0 no-repeat; margin: -0.938em 0 0 -44px; /* 15px */ height: 1em; } li input + ol &gt; li { display: none; margin-left: -14px !important; padding-left: 1px; } li label { background: url(folder-horizontal.png) 15px 1px no-repeat; cursor: pointer; display: block; padding-left: 37px; } li input:checked + ol { background: url(toggle-small.png) 40px 5px no-repeat; margin: -1.25em 0 0 -44px; /* 20px */ padding: 1.563em 0 0 80px; height: auto; } li input:checked + ol &gt; li { display: block; margin: 0 0 0.125em; /* 2px */} li input:checked + ol &gt; li:last-child { margin: 0 0 0.063em; /* 1px */ } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload