Creating a two column page - html

Right, so I want to create a page that has two columns and one header at the top of each one. I am using Vue.js to create this webpage. Ideally what I would want is to have the two headers at the top of the page with a gap in between and then the text and stuff below. I've tried to add the column break to make the right hand column start with the header, but it always starts a few lines below that and will not align with the other header.
As said I am using Vue.js, but I don't think that has anything to do with what I'm trying to achieve here. Please be lenient I'm very new to all this. I also tried adding the column feature in the CSS but that didn't work either.
The styles will then be stored in a different file.
I would appreciate any help on this matter. Thank you.
.commsHeaderleft {
width: 40%;
text-align: center;
}
.commsColumns {
align: left;
width: 100%;
text-align: justify;
column-count: 2;
column-gap: 40px;
}
.commsHeaderright {
width: 100%;
text-align: center;
}
<template>
<div>
<div class="commsHeaderleft">
<h1>Join us on Teamspeak!</h1>
</div>
<div class="commsColumns">
<p>--snip--</p>
<p>--snip--</p>
<p>Once installed set up a Bookmark to Air Combat Group using the following connection details and join in.</p>
<table id="tsDetails">
<tr>
<td>Address:</td>
<td>snip</td>
</tr>
<tr>
<td>Password:</td>
<td>No Password Set</td>
</tr>
</table>
<p>snip</p>
<p>snip</p>
<div class="commsHeaderright">
<h1>Check us out on Discord!</h1>
</div>
<p>snip</p>
<p>Discord is a free installation available <u>here</u></p>
<p>snip</p>
<table id="dsDetails">
<tr>
<td>Invite link:</td>
<td>https://discord.gg/snip</td>
</tr>
</table>
<br>
<p>snip</p>
<iframe src="https://discordapp.com/widget?id=261587898996883458&theme=dark" width="350" height="500" allowtransparency="true" frameborder="0"></iframe>
</div>
</div>
</template>

You can use flexbox to do that : https://css-tricks.com/snippets/css/a-guide-to-flexbox/
<div class="page">
<div class="header">
<div class="header__item">header 1</div>
<div class="header__item">header 2</div>
</div>
<div class="content">
content
</div>
</div>
.header{
display: flex;
margin: 0 0 30px 0;
}
.header__item{
flex: 1
}

Related

Stretch one div and display another one below to use entire parent div area but make the top div scrollable if too large

I need to have a div (divParent) which needs to have 2 other divs (divContainer, divButtons) where the divButton will display at the very bottom of the DivParent and the divContainer will use the entire remaining space of the divParent up to the divButton, but it cannot overlap the divButtons and if the content of the divContainer is too big, I need the vertical scrollbar to be displayed.
I've got the following more or less working but the divContainer seems to be overlapping the divButtons and it does not display the vertical scrollbar if the content is too big, even when I specify overflow: auto or overflow-y: auto.
<div id="divParent" style="width: 100%; height: 100%; background-color: red; position: relative">
<div id="divContainer" style="overflow-y:auto;">
<table id="fields">
<large content goes here>
</table>
</div>
<div id="divButtons" style="width: 100%; background-color: blue; position: absolute; bottom: 0">
<div style="float:right;">
<table>
<tr>
<td style="padding: 2px">
<div id="submitbutton">test1</div>
</td>
<td style="padding: 2px">
<div id="cancelbutton">test2</div>
</td>
</tr>
</table>
</div>
</div>
</div>
If I specify "max-height:100px" on the divContainer to test, it does exactly what I need where the vertical scrollbar is displayed but it's clearly no longer stretched all the way to the divButton.
Note that the divParent is then used in a third-party popup window.
Any suggestions?
Thanks.
I eventually figured it out, but credit to #Brad for his answer in:
from How do I make a div stretch in a flexbox of dynamic height?
I had to rejig a few things but eventually got there and my divs are defined as follows now:
<div id='divParent' style='display: flex;
flex-direction: column; height: 100%; width: 100%;'>
<div id='divContainer' style='width: 100%; flex-grow:1;
overflow: auto'>
<div id='divButtons' style='width: 100%; height: 40px;
margin-top: 5px'>
That'it!
Install bootstrap and you will have great control of div placements. Bootstrap creates 12 columns for each row:
<div class="row">
<div class="col-md-7" align="right">
<div class="row">
</div>
<div class="row">
</div>
</div>
<div class="col-md-3" align="left">
</div>
<div class="col-md-2" style="padding-right:2%;">
</div>
</div>

Switching from absolute back to static? relative?

I would like to create a somewhat complicated layout for a web page. I'll explain using table-tags, but in reality (I think) I want it in div-tags.
I need the structure to fill the whole screen - the left and right half (1-9 and 10-18) should each take half the screen.
In each half, I want the upper and lower bars to have a set number of pixels (50?), and the middle fields to take the whole rest of the screen, vertically. In fact, fields 5 and 14 will take the most of the screen.
I have been successful in creating this layout using css with div position=absolute, but the positioning of the 16 little fields is very ugly, tedious and most likely not the right way to do it. Once I used absolute positioning I cannot use margins to keep distances between the little blocks, but this would be convenient.
I found posts using display=block or inline-block, but these do not work once position=absolute is set (I think so at least). I cannot get them to work inside my left and right half screens.
Without absolute positioning I have not been able to do the first split so that the whole visible width is used, yet no scrollbars appear.
Is there a way to do that?
<table border="0">
<tr>
<td>
<table border="1">
<tr><td>01</td><td>02</td><td>03</td><td>04</td></tr>
<tr><td colspan=4><br/>05<br/></td></tr>
<tr><td>06</td><td>07</td><td>08</td><td>09</td></tr>
</table>
</td>
<td>
<table border="1">
<tr><td>10</td><td>11</td><td>12</td><td>13</td></tr>
<tr><td colspan=4><br/>14<br/></td></tr>
<tr><td>15</td><td>16</td><td>17</td><td>18</td></tr>
</table>
</td>
</tr>
</table>
You can use display: flex property for the same.
Flex will take care of positioning as well as width/height of the divs by itself. Also, you can apply margin/padding with ease.
Please find the code snippet.
Hope it helps.
.parent {
display: flex;
flex-direction: row;
}
.col {
display: flex;
flex-direction: column;
}
.row1 {
display: flex;
flex-direction: row;
height: 50px;
}
.row2 {
padding: 10px;
}
.row3 {
display: flex;
flex-direction: row;
height: 50px;
}
.content {
margin: 5px;
padding: 5px;
}
.row1, .row2, .row3, .content {
border: 1px solid #000;
}
<div class = "parent">
<div class = "col">
<div class = "row1">
<div class="content">1</div>
<div class="content">2</div>
<div class="content">3</div>
<div class="content">4</div>
</div>
<div class = "row2">
<div>5</div>
</div>
<div class = "row3">
<div class="content">6</div>
<div class="content">7</div>
<div class="content">8</div>
<div class="content">9</div>
</div>
</div>
<div class = "col">
<div class = "row1">
<div class="content">10</div>
<div class="content">11</div>
<div class="content">12</div>
<div class="content">13</div>
</div>
<div class = "row2">
<div>14</div>
</div>
<div class = "row3">
<div class="content">15</div>
<div class="content">16</div>
<div class="content">17</div>
<div class="content">18</div>
</div>
</div>
</div>

css pdf page - header overlapping with content

As we can see from the image my content overlaps with the header image and this is the code I have:
<style type="text/css" media="print">
#page {
/*size:landscape;*/
#top-center {
content: element(header);
}
#bottom-left {
content: element(footer);
}
}
div.header {
padding: 10px;
position: running(header);
}
div.footer {
display: block;
padding: 5px;
position: running(footer);
}
.pagenumber:before {
content: counter(page);
}
.pagecount:before {
content: counter(pages);
}
</style>
</head>
<div class="header">
<img src="logo.png" title="logo" width="200px"/>
</div>
<div class="content">
</div>
P.S.: Please don't close this question as duplicate as I have already searched all the questions related to the same but mine looks different as PDF is involved.
Headers and footers are established within the page margins.
So the solution is to increase the page top margin, for example:
#page {
margin-top: 50mm;
}
Method to implement header footer properly in PDF
After finding a lot on internet on different solutions and workaround, I'm finally sharing a way that works for me.
Please add these style to report container (the div in which report is rendered).
<div #scrollingContainer class="col-xxs-9 content-container" style="overflow-x: hidden;width:100%;">
</div>
// Div properties may differ
Wrap the Doc component into the table structure with thead and tfoot according to the size of your header and footer(table is wrapped inside a div).
<div style="width: 100%;">
<table style="table-layout: fixed; width: 100%;"> // Add this css to make main table fixed, child tables will still scroll
<thead class="page-break-before">
<tr>
<td>
<div style="height: 80px;"></div> // space for the respective header
</td>
</tr>
</thead>
<tbody>
<tr>
<td>
<div> Your Data Goes Here........</div>
</td>
</tr>
</tbody>
<tfoot class="show-in-print page-break-after">
<tr>
<td>
<div style="height: 130px;"></div> // space for the respective footer
</td>
</tr>
</tfoot>
</table>
</div>
Sample Header and footer
<div class="page-break-before">
<div>A long header content...</div>
</div>
<div class=" page-break-after">
<p> A long footer content...</p>
</div>

Align text next to a picture

How do I align the text as in the picture below?
<div id="contact-info">
<div id="contact-list">
<div id="adresa">
<img src="http://avocat.dac-proiect.ro/wp/wp-content/themes/twentyfourteen/images/ADRESA.png" style="width:22px;height:31px;float:left;">
<p style="text-align:center;">Calea Dorobantilor,nr.74</p>
<p style="text-align:center;">,bl.Y9,SC.2,Ap.25,Cluj-Napoca,400609,Romania</p>
</div
<div id="telefon"></div>
<div id="mail"></div>
</div>
</div>
#contact-info
{
width:300px;
height:300px;
background:url(images/BODY-CONTACT.png);
position:absolute;
right:0;
}
How can I solve this problem?
Fail to fix it as I want
www.avocat.dac-proiect.ro/wp
Generally, you should use div to nesting elements, in order to align them in a decent way. Also pay attention to the display:blockorinline. You could read more in W3C docs. My touch to this problem is as follow:
<div id="adresa">
<div id="addPadding" style="
padding: 2em;">
<img src="http://avocat.dac-proiect.ro/wp/wp-content/themes/twentyfourteen/images/ADRESA.png" style="width:22px;height:31px;float:left;display: inline;">
<div style="
float: right;
display: inline;
width: 80%;
">
<p style="text-align:left;">Calea Dorobantilor,nr.74,</p>
<p style="text-align:left;">bl.Y9,SC.2,Ap.25,<br>Cluj-Napoca,400609,
<br>Romania</p>
</div>
</div>
</div>
I used 2<div>, one wrap the two <p> and the other one wrap the <img>and the new '' (or you can just simply add padding on the <div id="adresa">).
it will get a more similar layout result to your mockup, I wish I could took screen shot for you.
you just need to fix the text-align:left and margin on <p>tag to finish your job.
NOTE: This is NOT the whole solution. I just gave you an idea about what approach should be used.
This is so simple ... For this you need to make <p> and <img> position: absolute;. like below
.centered {
position: absolute;
right: 12px;
top: 110px;
}
and add class to ps and img like
<p class="centered">....</p>
<img class="centered" src="...." />
Try this using different top and right values for each p and `img.
Although the CSS purists would tell you not to, I would just add a table
<table>
<tr>
<td>
<img src="http://avocat.dac-proiect.ro/wp/wp-content/themes/twentyfourteen/images/ADRESA.png" style="width:22px;height:31px;">
</td>
<td valign="top">
<p style="text-align:center;">Calea Dorobantilor,nr.74</p>
<p style="text-align:center;">,bl.Y9,SC.2,Ap.25,Cluj-Napoca,400609,Romania</p>
</td>
</tr>
</table>

HTML Stretch header and footer to long content without JS

I'm having a small issue here, I've made a jsfiddle for you guys to play with it: http://jsfiddle.net/darkguy2008/NQUz8/
The problem I have is that when there is unavoidable long content, the header and footer don't stretch to it, but to the maximum browser window.
I need to find a way to make it stretch, I've had an idea of having the header and footer be part of the content div instead, but if the content is shorter than the browser window they wouldn't stretch to 100% width of the browser window and that's what I don't want.
Also, the title/subtitle of the page can be longer than the content so that wouldn't help either :/
I would love to change the design, but it's for a report website, I can't put it with a margin: 0 auto; because the idea isn't to center the website or to make the reports a fixed width (because they can't, either).
The idea is also to avoid JS. I know I can fix the widths using JQuery, but the project can also be used by external clients so we can't enforce them to use JS. Weird I know but I've seen cases where the stupid sysadmins block JS and we can't do much about it, except to make it work.
I can use HTML5 and CSS3, so if there's a way to do it with those two technologies it would be great :)
Any ideas are welcome!
HTML:
<header>
<div class="wrap">
<table border="0">
<tr>
<td rowspan="2">
<img src="http://dummyimage.com/230x100/000/fff&text=LOGO" align="left" style="border-width:0px;" />
</td>
<td>
<h1>title 1 lololol</h1>
</td>
</tr>
<tr>
<td>
<h2>subtitle omgomgomgomgomg</h2>
</td>
</tr>
</table>
</div>
<div id="menu">menu goes here omg</div>
</header>
<div>contentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontent</div>
<footer>
<div class="wrap">
<p>Footer goes here o.o"</p>
</div>
</footer>
CSS:
/*********************/
/** RESET */
/*********************/
*
{
padding: 0;
margin: 0;
/*border: 0;*/
font-family: Arial;
}
/*********************/
/** Main CSS */
/*********************/
body
{
font-family: Arial;
font-size: 10pt;
}
.wrap
{
position: relative;
margin: 0 0;
width: 640px;
}
header, footer
{
background: #0f6;
float:left;
min-width:100%;
}
#menu
{
min-width: 100%;
border-top: 2px solid red;
border-bottom: 2px solid red;
}
th, td { padding: 0; }
table { border-collapse:collapse; border-spacing: 0; }
Basically you have to include the content and the footer inside your "header" element so your content will make it grow.
HTML
<div>
<header>
<div class="wrap">
<table border="0">
<tr>
<td rowspan="2">
<img src="http://dummyimage.com/230x100/000/fff&text=LOGO" align="left" style="border-width:0px;" />
</td>
<td>
<h1>title 1 lololol</h1>
</td>
</tr>
<tr>
<td>
<h2>subtitle omgomgomgomgomg</h2>
</td>
</tr>
</table>
</div>
<div id="menu">menu goes here omg</div>
<div class="content">contentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontentcontent</div>
<footer>
<div class="wrap">
<p>Footer goes here o.o"</p>
</div>
</footer>
</header>
</div>
Modifications in CSS:
.content
{
background: #FFFFFF;
}
Here is a working fiddle:
Fiddle
As in the last post, use the word-wrap here and set your width to whatever you want it to. I set it for you at 100% but it only goes to whatever the largest width you have. http://jsfiddle.net/NQUz8/2/
<div style="word-wrap:break-word; width="100%;">content here</div>
I would use some type of css class or id if you can. I just used style here to show you how it works.