CSS and Flying Saucer header - css

The company I work for has been using Flying Saucer for a while. Rencently, they have changed the header format to a complex one that looks like this:
THE COMPANY NAME
_____________________________________________________________________________
This is the name of the article | Date:04/17/2013
_____________________________________________________________________________
Regrettfully, I can't get it to look like above. THe closes I can get it to look like is where the top line is shorter then the bottom line:
THE COMPANY NAME
____________________________________________________________________
This is the name of the article | Date:04/17/2013
_____________________________________________________________________________
Here is the code:
#page {
size:letter;
margin-top: 0.8in;
margin-bottom: 0.5in;
padding: 5px;
border-top:#90aac5 solid 1px;
#top-left {content: element(leftHeader);}
#top-center{content: element(centerHeader);}
#top-right {content: element(rightHeader);}
}
#page-thisheader-center {
position:running(centerHeader);
border-bottom:#90aac5 1px solid;
font-size:9px;
height:52px;
color:#7e7f7f;
padding:2px;
}
#page-header-right {
position:running(rightHeader);
border-top:#90aac5 1px solid;
height: 25px;
font-size:9px;
color:#7e7f7f;
white-space:nowrap;
float:right;
padding-top:5px;
}
#page-header-left {
position:running(leftHeader);
border-top:#90aac5 1px solid;
height: 25px;
font-size:9px;
color:#7e7f7f;
float:left;
padding-top:5px;
}
.date {
height: 15px;
border-left: #90aac5 solid 1px;
float:right;
width:75px;
The tag looks like this for ids and classes above:
<div id ="page-header-left" align="left">
<div> <xsl:call-template name="get.title"/></div>
</div>
<div id ="page-header-right" align="right">
<div class="date"> <xsl:call-template name="get.date"/></div>
</div>
<div id ="page-thisheader-center">
<div> <xsl:call-template name="get.company.name"/></div>
</div>
I think that is all of it. I hope someone can help. I am totally stumped on how to correct the top line. Thanks!!
UPDATE
The short line is due to the longer titles wrapping. Is there a way to fix the #top-left, #top-center and #top-right margins to a fixed width so the title can wrap without causing the whole header to slide smaller/bigger depending on the title? BTW: I have tried whitespace: nowrap; on the #top-left margin but that just causes the whole header to slide off the right hand side of the page with long titles.
I hope this helps for a solution. Thanks in advance!!

I don't know if it's possible to do what you want using #top-left, #top-center and #top-right. When i try your sample code, I get something like this :
THE COMPANY NAME
____________________________________________________________________
_____ ____
title date
One solution to get what you want would be to use a single #top-center header, containing the three parts of the header.
The #top-center component will span on the full width of the page, and you can layout your
three divs inside it.
For example :
#page {
size: letter;
margin-top: 0.8in;
margin-bottom: 0.5in;
#top-center {content: element(centerHeader);}
}
#page-thisheader-center {
position: running(centerHeader);
}
#company {
border-bottom: #90aac5 1px solid;
text-align:center;
}
#line2 {
border-bottom: #90aac5 1px solid;
}
#article{
float:left;
}
#date {
border-left: #90aac5 solid 1px;
margin-left: 6in;
}
And :
<div id="page-thisheader-center">
<div id="company">THE COMPANY NAME</div>
<div id="line2">
<div id="article">Name of the article</div>
<div id="date">Date : 04/07/2013</div>
</div>
</div>

Related

CSS for Printing onto Perforated Cards

I have a dataset, and I need to print data onto these cards (one row of data per card):
magnatag.com
I am having a real hard time with the formatting. The printer they are being printed on can print all the way to .2 from the edge of 8.5 x 11 paper like this. The users want to print that far to the left and right, but the rows have to stay within card boundaries obviously.
The cards being used are all white, and one of the data points is a color the card will be printed in. To keep the example easier/cleaner than the real life problem, assume this markup:
<body>
<div class="cardSheet">
<div class="card blue">Content</div>
<div class="card red">Content</div>
<div class="card green">Content</div>
<div class="card green">Content</div>
<div class="card red">Content</div>
<div class="card blue">Content</div>
<div class="card green">Content</div>
<div class="card red">Content</div>
<div class="card green">Content</div>
<div class="card green">Content</div>
</div>
</body>
After the fifth row, the next row will print on the second page, etc.
There is a good bit of formatting within an individual card, but I think I can handle that. Getting 5 printable boxes per page that will print onto these cards (with .21" left and right margins in print preview, top/bottom per the card)
If varying browsers adds complexity, assume Google Chrome v 53.x
Thanks in advance for any help!
You will need to put this on a page by itself to test it. I did a few runs but I dont have any letter size pager here only a4 to test. It looks like it will work though. I used chrome and set margins to none in the print options.
I only did a quick run to show one page but you can easily add a page break after the 5th card to go to the next page. If you dont know how to do that then I can help out later with that.
Hope this helps and if you need help understanding something leave a comment.
printBlock("blue");
printBlock("red");
printBlock("green");
printBlock("green");
printBlock("red");
function printBlock(color) {
var block = "<div class='card " + color + "'>CONTENT<div>";
$(".page").append(block);
}
* {
margin: 0px;
padding: 0px;
}
body {
margin: 0;
padding: 0;
}
* {
box-sizing: border-box;
-moz-box-sizing: border-box;
}
.page {
width: 215.9mm;
min-height: 279.4mm;
margin: 1cm auto;
position: relative;
padding-left: 6.35mm;
padding-top: 19.05mm;
outline: 1px solid cyan;
}
.card {
position: relative;
width: 203.2mm;
height: 50.8mm;
background-color: #FFF;
float: left;
outline: 1px dashed #000;
padding-left: 20px;
padding-right: 20px;
padding-top: 15px;
}
.blue {
background-color: #DBFFFF;
}
.red {
background-color: #FFDBDB;
}
.green {
background-color: #EDFFDB;
}
#page {
size: 215.9mm 279.4mm;
margin: 0;
}
#media print {
.page {
margin: 0;
border: initial;
width: 215.9mm;
min-height: initial;
box-shadow: initial;
background: initial;
outline: none;
}
.card {
outline: none;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<div class="page"></div>

Preventing Div Elements From Wrapping in a Fluid Navigation

I have a top nav that extends across the page
Within that top nav I have various elements
two that must align left
one that must align right
The nav is fluid the elements are fixed widths
Do not want the elements to wrap when the browser window is minimized
Needs to work in IE6 on up due to high Chinese audience.
See example here:
http://jsfiddle.net/4SUwg/
<div id="header">
<div id="headerContent">
<div class="search-list"> Search List </div>
<div class="social-buttons"> Social </div>
<div class="signin"> Login Drop Down </div>
</div>
</div>
I would like the div elements within the nav to not wrap. I searched around on stack and could find answers that come close but nothing that completely addressed the issue. My need to have the div element aligned right complicates matters. Must work in all browsers, especially IE's.
Thanks all for your help in advance!!!
Use SPAN .. It's INLINE and not BLOCK ??
<div id="header">
<div id="headerContent">
<span class="search-list"> Search List </span>
<span class="social-buttons"> Social </span>
<span class="signin"> Login Drop Down </span>
</div>
</div>
And your CSS, remove floats
<style>
body {
margin:0;
padding:0;
}
#header {
background: #404040;
height: 35px;
color: white;
margin: 0 0 12px 0;
overflow-x:auto; overflow-y:hidden;
}
#headerContent {
height: 32px;
border:1px dashed #fff;
}
.search-list {
width:150px;
background:#039;
}
.social-buttons {
width:150px;
background:#060;
}
.signin {
width:200px;
background:#F00;
}
You want a fluid layout but the most important rule of a fluid layout is not to set a definite width of elements but you have set the width.
The CSS have a <style> tag, which is not required, probably you put it by mistake.
I have set the width of divs inside headerContent in percentage value. The CSS is
body {
margin:0;
padding:0;
}
#header {
background: #404040;
height: 35px;
color: white;
margin: 0 0 12px 0;
overflow-x:auto; overflow-y:hidden;
}
#headerContent {
height: 32px;
border:1px dashed #fff;
}
.search-list {
width:28%;
float:left;
background:#039;
}
.social-buttons {
width:28%;
float:left;
background:#060;
}
.signin {
width:28%;
float:right;
background:#F00;
}
Just changed the width value and on my browser it looked fine, better than the before version. Here's a fiddle http://jsfiddle.net/DeepakKamat/s52Hn/8/
I found a solution that works in all browsers, specifically IE6 on up since that was a requirement for this project. If you have something better that accomplishes the same thing please post! My sincere thanks to everyone who answered/helped.
<div id="header2">
<table id="headerContent2">
<tr>
<td id="left" valign="top">
<div id="leftWrapper">
<div class="search-list2">Search List</div>
<div class="social-buttons2">Social Buttons</div>
</div>
</td>
<td id="middle"> </td>
<td id="right" valign="top">
<div class="signin2">Login Drop Down</div>
</td>
</tr>
</table>
</div>
<style>
#header2 {
background: #404040;
height: 35px;
color: white;
margin: 0 0 12px 0;
}
#headerContent2 {
width:100%;
}
#headerContent2 td {
height: 32px;
padding:0;
margin:0;
}
.search-list2 {
width:150px;
float:left;
background:#039;
}
.social-buttons2 {
width:200px;
float:left;
background:#060;
}
.signin2 {
background:#F00;
float:right;
width:400px;
}
#leftWrapper {
width:400px;
}
#middle {
width:100%;
}
</style>
See Demo of it working here. Copy the code and try it out in all the IE's since JSfiddle does not work in all IE's.
http://jsfiddle.net/GtXKE/

CSS Fixed Position overlapping each other

Basically I'm making a navigation bar and due to Jquery doing a lot of resizing to make a website look 'pretty' I don't want to use a horizontal list and so each button is created like so:
<img src="homeicon.png"><span id="homex"><br /><img src="home.png" /></span>
(yes they're all image buttons for good reason)
but the only problem is they're fixed and set to "top 0" at the top of the page and as a result cannot sit next to each other but rather overlap, any idea on how I can I still keep the position to fixed and they top to 0 yet keep them next to each other?
HTML
<div id="top">
<img src="homeicon.png"><span id="homex"><br /><img src="home.png" /></span>
</div>
CSS
#top a.button { position: fixed; top: 0; padding: 12px; background: url('glacial_ice.jpg'); text-decoration: none; color: black; border-radius: 0px 0px 25px 25px; }
#top { position: relative; top:0; padding-left: 25px; }
Init function (runs on $(document).ready())
$('a.button').animate({
height: '+=5px',
}, 20, function() {
$('a.button').animate({
opacity: 0.6,
height: '-=5px',
}, 20);
});
Thanks
Put them all in a container, i.e. id="header", give the header position:fixed;top:0;etc...
Then, for each of the link/buttons give them:
position:relative;display:inline-block;float:left;
if you want them centered, then in the #header use text-align:center; and remove float:left from the links
So the container will be fixed, but the buttons inside will be relative and not overlap.
hope this helps!
very crude example
http://jsfiddle.net/6SCTZ/
<div id="header">
<div class="button">button1</div>
<div class="button">button2</div>
<div class="button">button3</div>
</div>
CSS:
#header { position:fixed;top:0;width:100%;height:30px;background:black; text-align:center }
.button {position:relative;display:inline-block;color:white;margin:0 5px 0 5px;}
Just put whatever elements need to be fixed within a container element (in this case, I'll use a div with an ID of "top_fixed").
Consider the following html:
<div id='top_fixed'>
<a href='http://google.com'>Google</a>
<a href='http://yahoo.com'>Yahoo</a>
</div>
<div id='tall'></div>
Now, the following CSS:
a { display: inline; }
#top_fixed { position: fixed; top: 0; left: 0; width: auto; }
#tall {height: 2000px; background: #000;}
​
DEMO: http://jsfiddle.net/mHKNc/1/

Multi-column CSS layout with rounded borders

Problem:
I am trying to create a multi-column CSS layout with borders that look something in line with this picture:
Code:
<div style="border-radius:4px; border: 1px solid #ddd;">
<div style="display:block;float:left;width:50%;">
<div><b>Författare:</b> '.$authors.'<br></div>
<b>Handledare:</b> '.$row['Supervisor'].'<br>
<b>Examinator:</b> '.$row['Examiner'].'<br>
<b>Design av studie:</b> '.$design.'
</div>
<div style="display:block;float:left;width:50%;">
<b>Examinationsdatum:</b> '.$row['ExaminationDate'].'<br>
<b>Nivå:</b> '.$level.' ('.$credits.')<br>
<b>Kommentar:</b> '.$row['Comments'].'<br>
<b>Övrigt:</b> '.$row['Participants'].' deltagare, '.$row['Reference'].' referenser
</div>
</div>
The above-mentioned code will produce the following:
Question:
What needs to be modified so I can get the horizontal and vertical lines to the box?
You can modify the CSS to look like this:
.row {
border: 1px solid #ddd;
margin-bottom: -1px;
}
.left {
display: inline-block;
width: 50%;
border-right: 1px solid #ddd;
}
.right {
display: inline-block;
width: 49%;
border-left: 1px solid #ddd;
margin-left: -1px;
}
.top {
border-top-right-radius: 4px;
border-top-left-radius: 4px;
}
.bottom {
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px;
}
.outerBox {
margin: 10px;
}​
Then have your markup look like this:
<div class="outerBox">
<div class="row top">
<span class="left"><b>Författare:</b> '.$authors.'</span><span class="right"><b>Examinationsdatum:</b> '.$row['ExaminationDate'].'</span>
</div>
<div class="row">
<span class="left"><b>Handledare:</b> '.$row['Supervisor'].'</span><span class="right"><b>Nivå:</b> '.$level.' ('.$credits.')</span>
</div>
<div class="row">
<span class="left"><b>Examinator:</b> '.$row['Examiner'].'</span><span class="right"><b>Kommentar:</b> '.$row['Comments'].'</span>
</div>
<div class="row bottom">
<span class="left"><b>Design av studie:</b> '.$design.'</span><span class="right"><b>Övrigt:</b> '.$row['Participants'].' deltagare, '.$row['Reference'].' referenser</span>
</div>
</div>
CAVEAT: The formatting will break if you put a space between the spans on an individual line, so don't break them; otherwise, take this solution and work out something that doesn't break =) ​
You can see a working example at http://jsfiddle.net/saluce/XhnBE/
EDIT: It seems that mPDF doesn't like inline-block, so change this part of your CSS:
.left {
display: block;
float: left;
width: 50%;
border-right: 1px solid #ddd;
}
http://jsfiddle.net/saluce/XhnBE/1/
You could use two lists side by side:
<div style="border-radius:4px; border: 1px solid #ddd;">
<ul style="display:block;float:left;width:50%;">
<li><b>Författare:</b> '.$authors.'</li>
<li><b>Handledare:</b> '.$row['Supervisor'].'</li>
<li><b>Examinator:</b> '.$row['Examiner'].'</li>
<li><b>Design av studie:</b> '.$design.'</li>
</ul>
<ul style="display:block;float:left;width:50%;">
<li><b>Examinationsdatum:</b> '.$row['ExaminationDate'].'</li>
<li><b>Nivå:</b> '.$level.' ('.$credits.')</li>
<li><b>Kommentar:</b> '.$row['Comments'].'</li>
<li><b>Övrigt:</b> '.$row['Participants'].' deltagare, '.$row['Reference'].' referenser</li>
</ul>
</div>
You'll need to add some styles to get rid of the default styles for lists and add you borders to the top, bottom and sides of your lis .
A down side of this is that you'll have to give your lis fixed heights so the borders line up.
You have to change your marke-up. You need a table or more boxes to do this. I think tables would be easier to manage... and somehow this is a case tables are for.
Or you take a bg-image... but I won't recommend this
Check this: http://jsfiddle.net/eNEzs/
It's enough to correct your css a little bit and wrapp items in div's.
<div style="border-radius:4px; border: 1px solid #ddd; margin: 20px;">
<div class="block">
<div><b>Författare:</b> '.$authors.'</div>
<div><b>Handledare:</b> '.$row['Supervisor'].'</div>
<div><b>Examinator:</b> '.$row['Examiner'].'</div>
<div><b>Design av studie:</b> '.$design.'</div>
</div>
<div class="block">
<div><b>Examinationsdatum:</b> '.$row['ExaminationDate'].'</div>
<div><b>Nivå:</b> '.$level.' ('.$credits.')</div>
<div><b>Kommentar:</b> '.$row['Comments'].'</div>
<div><b>Övrigt:</b> '.$row['Participants'].</div>
</div>
<div style="clear:both"></div>
</div>​
CSS
.block {
display:block;
float:left;
width:50%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.block:first-child {
border-right: 1px solid #ddd;
}
.block div {
border-bottom: 1px solid #ddd;
}
.block div:last-child {
border-bottom: 0px;
}
But I would recommend you to simply change elements to a table or list (ul or ol). Above solution is simply for this particular exmaple.
Wrap each cell in a div instead of using br, and add border-left and border-bottom on the appropriate element. If you still want to use 50% width, then use box-sizing: border-box; to keep it from wrapping.
See this jsfiddle for one way to do it, though you should use classes to properly select which elements to apply the different styles to.

CSS: positioning an image on left of two lines of text

Like the title says I wan't to create a clickable list, in which each element contains an image on the left and two lines of text on the right.
Right now I've manage to implement the elements with the following code:
HTML:
<div class="verticalListItem">
<a href="#">
<div class="verticalItemImage"><img src="images/vdfLogo.png" width="80" height="80" /></div>
<div class="verticalItemText">
<p>Pop/Rock</p>
<p>0</p>
</div>
</a>
</div>
CSS:
.verticalListItem {
border: 1px solid #333;
}
.verticalItemImage {
float: left
}
.verticalItemImage img {
display: block;
}
The result I have now is this:
However, my red image is not centered vertically and worst: the area bellow the image and the second label, so as the area above the first label (I've marked those areas with green on second element) is not clickable. What am I doing wrong here, can you help me please?
Thanks in advance!
here is the solution - http://jsfiddle.net/SaRnR/
Not sure without testing, but this should work for you.
.verticalListItem {
border: 1px solid #333;
}
.verticalListItem a {
overflow: auto;
}
.verticalItemImage {
float: left;
}
.verticalItemImage img {
display: block;
}
.verticalItemText {
float: left;
display: block;
line-height: 40px;
}

Resources