I recently saw a site that had the blog aligned to the right hand side of the screen (so any extra space was on the left of the main column. Unfortunately, it was Wordpress and all I can seem to find when I search for aligning blog templates to the right is stuff about right aligning pictures.
I suppose could add padding (trial and error) on that side to bump it across, but that wouldn't display properly on other computers.
My sidebar is 325 wide and the main column is 625, leaving ~240 on the left.
I'm just using the Simple template as a base. I don't know that it's worth the time that it would take to do it from scratch. Or that I have the skills :. The Blogger help areas are practically abandoned.
Is this possible? Or are there any other ideas that could work across different computers/resolutions?
Whatever element you want to align to the right , enclose it in a div and make it float right ? Wouldn't this work?
...
<div style="float:right">
<div class='sidebar'>...</div>
<div class='main-column'>...</div>
</div>
...
This is a very basic CSS design question.
When I have two block-elements
+----------+ +----------+
|~~~~~~~~~~| |**********|
|~~~~~~~~~~| |**********|
|~~~~~~~~~~| |**********|
+----------+ +----------+
and I want to set the space between them, there are three possibilities:
Left block with right margin
Right block with left margin
Margin for both blocks
What are the pros and cons for each one and—most importantly—what is considered
best practice?
It is generally a good idea to choose a direction (margin-left OR margin-right) and to stick to it on the whole project so designing will be easier and more consistent.
For more on the subject you can read this blog post: Single-direction margin declarations
That said, margin-left on boxes means "I do not want to be too close to the box before me" while margin-right means "I do not want other boxes to be too close to me".
So on designs where boxes have a margin by default, use margin-right (and margin-bottom) and on designs where boxes have no margin by default, use margin-left (and margin-top) on the few boxes with a margin. If it is mixed, choose the direction that seems the most coherent to you and stick to it.
No pros and cons, it is totally on your design, what you want to go for, using margin-right will make the last element have margin-right for no good reason, so say for example, you have three boxes, floated to the left, or they are displayed inline-block so because of the right margin, the last box won't touch the extreme right of the template, instead it will wrap and move down.
Do you see the red space, it's margin-right for the last element, which you won't need. shifting it more will result your div to move down.
Solution?
If you are willing to support legacy browsers, assign a class to the last element and write margin-right: 0;, say you are having 3 li elements floated, so you will write
ul.class_name li.class_name {
margin-right: 0;
}
Else, you can use :last-child pseudo to get rid of the extra margin.
So it will be
ul.class_name li:last-child {
margin-right: 0;
}
Same thing will go for the left, but instead of using :last-child and margin-right you need to use margin-left and :first-child respectively.
Last but not the least, using margin on both sides, will create a space on both the sides, again, resulting in disorientation of your layout.
In the above case, you will have to use both, either assign class to first and last element, or you need to use :first-child and :last-child to get rid of margin on the left for first element and margin on the right for last element.
Conclusion: For the two boxes you have, you should use margin-right
and use a class or :last-child to remove the extra margin on the
last element.
It depends where you will use it and how you will use it there is no exact rule for this. However if you will use some grid system for elements it is best practice. If your element cannot be suitable for grid system you can use any approach.
P.S. And there is another possibility to use pseudo element after or before I guess.
Simple Answer: It depends
It all depends on what you are trying to do, and what elements are those.
For example, if your site is oriented to the left, and those are two floating divs, with the same class, you wouldn't want to use margin-left, because that will introduce some space on the left of the first block.
It obviously makes no sense to add margin to both elements, unless you have dynamic content that may appear in between.
So, other than the obvious styling manner that you want your page to have, there is no difference in performance, but mostly readability of your code
When printing a QTextDocument with doc->print() I almost cannot see the horizontal rules inserted by <hr>. When printing to PDF these are clearly visible. But when printed to a printer these lines are very very thin lines, almost invisible on the paper.
How do I fix this? I currently helped myself by inserting an <img> with a black pixel but this is very cumbersome as I have to exactly figure out the proper pixel width by trial and error.
<hr> tag supports the width attribute, which can be specified as an absolute or relative (%) value. E.g.:
<hr width=3>
I'm trying to typeset something in LaTeX and I would like to know if I'm doing it right. The basic idea is that section number hangs in the left margin. The number takes the height of the header+2 lines for a chapter heading, +1 line for section heading, and has the same height as the header for subsections, and is aligned to the top of the heading. See the following image to get an idea of what I'm talking about:
http://img62.imageshack.us/img62/8404/bladld.png
My approach is using titlesec and doing something like this:
\titleformat{\chapter}%
{\Huge\bfseries\sffamily}% format
{\vbox to 16pt{\llap{% label
\fontsize{3em}{0}\selectfont{\thechapter}%
\hskip 9pt%
}}}%
{0pt}% horizontal sep
{}% before
\titlespacing*{\chapter}%
{0pt}% left
{-2em}% before
{0pt}% after
But this solution has some hacks that I would rather avoid. The \vbox height for instance, is found by trial and error. Visually, it looks almost right...
Try using the memoir document class. That has a ton of options for doing exactly this kind of thing, and it's much neater...
There's a hangnum style and for sections, there's a \hangsecnum option, but that only puts the number in the margin: it doesn't make it bigger. Memoir is also fabulously documented. So I expect all everything you need will be there. The code for hangnum is on p.88 of the fantastic memoir manual. So from there and from later examples you should get all the pointers you need to get what you want...
I have a two-column paper where space restrictions are very tight.
I just looked at my last version of the manuscript and saw that the upper half contains a figure (as expected), but in the lower half there is a lot of vertical space between paragraphs (enough to squeeze 10 more lines), and that LaTeX probably added it so that in the beginning of the next page a new numbered section will begin at the top of the page.
I know there's a way to adjust this so LaTeX doesn't try so hard, but I'm not sure how. any help? Thanks!
The parameter that controls inter-paragraph spacing is called \parskip(See Paragraph Spacing ). You set it (with "rubber" values) using something like:
\setlength{\parskip}{1cm plus4mm minus3mm}
The defualt value of \parskip is class dependent. The "plus" and "minus" parts tell TeX how much it can adjust the value to improve the layout (that is they make the spacing elastic, thus the "rubber" designation). Reducing (or eliminating) the "plus" part of the rubber might help.
Watch out though, you can cause other layout artifacts if you constrain TeX too much.
Other things to think about:
The widow and club penalties probably apply section headings, and may be affecting TeX's layout choices (see https://stackoverflow.com/questions/512967/how-can-one-keep-a-section-from-being-at-the-end-of-a-page-in-latex for a discussion).
You may also want to consider messing with \baselineskip which controls the allowed spacing between lines of text and can also have rubber values.
This is a common problem, and there are probably some fairly sophisticated treatments already prepared on CTAN.
\vfill before the new section worked perfectly for me.