Vertical align text in cell - html

Is it possible to align text in a cell?
In my example I want to align hours and city centrally like this:
PLUNKER
#presentation {
background-color: #dedede;
padding-top: 25px;
padding-left: 50px;
padding-right: 50px;
}
#offers h1 {
text-transform: uppercase;
color: #666666;
}
#offers h1 em {
color: #4598d1;
font-style: normal;
}
.offers {
padding: 25px 50px;
width: 50%;
margin: auto;
}
.offers button {
background-color: #dddddd;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
color: #868686;
border: #868686;
border-style: solid;
border-width: 1px;
}
.offers .right {
float: right;
width: 100px;
}
.offers table {
background-color: #DEDEDE;
text-align: left;
float: left;
}
.offers .tittle {
font-size: 18px;
color: #666666;
font-family: 'Arial Normal', 'Arial';
text-transform: uppercase;
}
.offers th {
font-family: 'Arial Normal', 'Arial';
font-weight: 400;
font-size: 11px;
white-space: nowrap;
}
.offers table th .fistClass {
font-family: 'Arial Gras', 'Arial';
font-weight: 700;
font-style: normal;
font-size: 12px;
color: #669900;
text-align: center;
}
.offers table .td {
background-color: #ffffff;
}
.offers .departureTime {
color: #35A6F4;
font-size: 18px;
font-weight: bold;
}
.offers .arrivalTime {
color: #35A6F4;
font-size: 11px;
}
.offers .originStation {
font-family: 'Arial Gras', 'Arial';
font-weight: bold;
font-style: normal;
font-size: 11px;
}
.offers .destinationStation {
font-family: 'Arial Gras', 'Arial';
font-style: normal;
font-size: 11px;
}
.offers .duration {
font-size: 11px;
color: #666666;
}
.offers .priceFirstClass {
color: #7ABB00;
text-align: right;
font-family: 'Arial Gras', 'Arial';
font-weight: bold;
font-size: 20px;
}
.offers .minPrice {
}
.offers .lastPlaces {
}
.offers .unavailable {
font-size: 12px;
color: #E4E4E4;
text-align: center;
}
.offers .foo {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: auto;
}
.offers p.espacement_important {
margin: 5px 0;
}
.offers span{
padding-left: 15px;
}
<div id="presentation">
<section>
<div class="offers">
<table border="0">
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
<tr>
<td>
<div>
<p>
<span class="departureTime">03h00</span>
<span>New-York</span>
</p>
<p>
<span class="arrivalTime">15h00</span>
<span>Bahamas</span>
</p>
<p class="duration"><span >8h00</span>
<span>2 correspond.</span>
<span>A380</span>
</p>
</div>
</td>
<td class="unavailable">indisponible</td>
<td><input type="radio" />
<label >10.00 €</label>
</td>
<td>
<label >50.00 €</label>
</td>
</tr>
</table>
</div>
</section>
</div>

Try below code.
HTML
<div id="presentation">
<section>
<div class="offers">
<table class="locationtable" width="100%;" cellpadding="0">
<tr>
<td width="50%"><span class="departureTime">03h00</span></td>
<td width="50%"><span>New-York</span></td>
</tr>
<tr>
<td class="duration">8h00</td>
<td><span>Bahamas</span></td>
</tr>
</table>
</div>
</section>
CSS
.locationtable{
width: 200px;
margin: 0 auto;
background: #eee;
}
table td{
padding: 5px 10px;
vertical-align: middle;
text-align: center;
}
.departureTime,
.duration{
color: blue;
}
JSFIDDLE DEMO

What you want to do, is to force the text on a unique line.
I can think now of two solutions to proceed so.
The first one, would be to give to the cell that contains your text a minimum width that would always allow the text to display on one line, but, what if a new longer station name is created forward ?
The second solution is to force the text on one line with a css property call "white-space", and, in a table cell it will automatically resize the "td" to fit your text :
.offers td:first-child p{
white-space:nowrap;
}

Related

How to center a navbar under a heading?

I have a problem laying out and centering the navbar and the table. I want the navbar to be right under the h2 element and centered. At the moment, the navbar breaks onto the next line. The layout of the table is fine, but it should be centered. I wonder if there is a better technique for making a navbar.
Here is my code:
* {
background-color: #2c2f33;
text-decoration: none;
}
.bet-table {
display: table-cell;
margin: 0;
color: white;
}
.bet-table th,
td {
border: 1px solid;
text-align: center;
padding: 5px 5px 5px;
}
.bet-table table {
margin-left: auto;
margin-right: auto;
}
.logo {
text-align: center;
font-size: 40px;
font-family: arial;
font-weight: lighter;
color: white;
}
.nav-g ul {
list-style: none;
padding: 0;
margin: 0;
}
.nav-g li {
list-style: none;
display: inline-block;
}
.nav-g a {
text-decoration: none;
width: 100px;
display: block;
padding: 2px 2px 2px;
font-size: 15px;
font-weight: lighter;
text-align: center;
color: white;
font-family: arial;
float: left;
}
.Choose h3 {
color: white;
background-color: #7289da;
padding: 8px 8px 8px 8px;
border: 1px solid black;
font-family: Arial, Helvetica, sans-serif;
font-weight: lighter;
margin-top: 5pc;
}
.navbar a:hover {
color: #7289da;
}
<div id="h-container">
<h2 class="logo">Betbowl
<h2>
<div class="nav-g">
<ul>
<li><a href="#">Make-A-Bet</li>
<li><a href="#">Pending</li>
<li><a href="#">Completed</li>
</ul>
</div>
</div>
<div class="Choose">
<h3>Choose</h3>
</div>
<div class="bet-table">
<table style="width:100%; margin-left: auto; margin-right: auto;">
<tr>
<th>Situation</th>
<th>Bet</th>
<th>Winner</th>
<th>Earnings</th>
</tr>
<tr>
<td>blank</td>
<td>blank</td>
<td>blank</td>
<td>blank</td>
</tr>
<tr>
<td>blank</td>
<td>blank</td>
<td>blank</td>
<td>blank</td>
</tr>
<tr>
</tr>
</table>
</div>
</div>
First you need to close your <a> tags. like this:
I AM A LINK
ul needs to be centered:
text-align:center
for the table you should remove display property from the container, default value works fine:
.bet-table{
/* display: table-cell; REMOVE THIS LINE */
margin: 0;
color: white;
text-align: center;
width: 100%;
}
table{
margin: 0 auto
}
find the edited version here: https://codepen.io/theBehrouz/pen/QWmXZbr

Cant get border to extend HTML Outlook

I am trying to create a certificate in an html email. I cannot get the border to extend to the right alignment. Below is my code and an image of it. I know that html in outlook doesnt behave the same way but I do want instructor and manager on the same line inside the border. Float doesnt work and I could not get the margins to work.
CSS Code
<pre>
<style>
.cert {
border: 15px solid #0072c6;
border-right: 15px solid #0894fb;
border-left: 15px solid #0894fb;
width: 700px;
font-family: arial;
color: #383737;
overflow: visible;
}
.crt_title {
margin-top: 30px;
font-family: "Satisfy", cursive;
font-size: 40px;
letter-spacing: 1px;
color: #0060a9;
}
.crt_logo img {
width: 130px;
height: auto;
margin: auto;
padding: 30px;
}
.colorGreen {
color: #27ae60;
}
.crt_user {
display: inline-block;
width: 20%;
padding: 5px 25px;
margin-bottom: 0px;
padding-bottom: 0px;
font-family: "Satisfy", cursive;
font-size: 40px;
border-bottom: 1px dashed #cecece;
}
.signature{
font-family: 'Brush Script MT', cursive;
font-size: 40px;
letter-spacing: 3px;
text-decoration: underline;
}
.normal{
font-family: 'Arial';
font-size: 40px;
letter-spacing: 3px;
}
.afterName {
font-weight: 100;
color: #383737;
}
.colorGrey {
color: grey;
}
.certSign {
width: 200px;
}
#media (max-width: 700px) {
.cert {
width: 100%;
}
.tableClass {
margin: 0px 0px 0px 0px !important;
padding: 0px 0px 20px 0px !important;
}
</style>
</pre>
HTML Code
<table al[![enter image description here][1]][1]ign="center" width="600" border="0" cellpadding="0" cellspacing="0" class="cert">
<tr>
<td width="70%" align="center" class="crt_logo">
<img src="logo path"width="200" height="121" alt="logo">
</td>
</tr>
<tr>
<td width="70%" align="center">
<h1 class="crt_title">Certificate Of Completion
<h2>This Certificate is awarded to</h2>
<h1 class="colorGreen crt_user">Name</h1>
<h3 class="afterName">For completion in Class
</h3>
<h3>Awarded on Date taken</h3></td>
</tr>
<tr>
<td align="left" valign ="middle" style="font-family: 'Brush Script MT', cursive;
font-size:30px; text-decoration: underline;display:inline:">Instructor </td>
<td width="10px" align="left" valign ="middle" style="font-family: 'Brush Script MT',
cursive; font-size:30px; text-decoration: underline;display:inline:">Manager</td>
</td>
</td>
</tr>
</table>

How to align header to top of the page?

I'm new here and I was wondering: how do I align my header to the top of the page? Right now there is too much white space between the header and top of the page. Is there a way to 'valign' it to the top somehow? Any help is appreciated. Thank you. Attached is my html code as well as CSS.
#charset "UTF-8";
/* CSS Document */
body {
margin: 0;
padding-top: 0;
padding-left: 10px;
padding-right: 10px;
font-family: Helvetica, sans-serif;
color: #666;
}
h1 {
color: #333;
font-size: 32px;
line-height: 38px;
font-weight: 700;
text-align: center;
margin-bottom: 15px;
}
h2 {
color: #fff;
font-family: Minion Pro, Times New Roman, serif;
font-size: 42px;
font-weight: 700;
font-style: italic;
text-align: center;
padding-top: 25px;
margin-bottom: 15px;
}
h3 {
color: #333;
font-size: 26px;
font-weight: 700;
text-align: center;
}
h5 {
font-size: 18px;
font-weight: normal;
text-align: center;
margin-top: 0;
}
p,
ul {
font-size: 16px;
line-height: 23px;
font-weight: normal;
text-align: left;
}
.container {
padding-right: 15px;
padding-left: 15px;
padding-top: 10px;
padding-bottom: 15px;
margin-right: auto;
margin-left: auto;
max-width: 850px;
}
.container2 {
padding-top: 10px;
padding-left: 25px;
padding-right: 25px;
padding-bottom: 10px;
background-color: #dce4ea;
margin-right: auto;
margin-left: auto;
max-width: 850px;
}
.container3 {
background-color: #375e97;
margin-right: auto;
margin-left: auto;
max-width: 850px;
top: 0;
}
.container4 {
padding-right: 15px;
padding-left: 15px;
padding-top: 25px;
padding-bottom: 15px;
margin-right: auto;
margin-left: auto;
max-width: 850px;
}
.center {
display: block;
margin-left: auto;
margin-right: auto;
}
.subhead {
color: #fff;
font-family: Minion Pro, Times New Roman, serif;
font-size: 28px;
font-weight: normal;
font-style: italic;
text-align: center;
padding-bottom: 25px;
margin-top: 0px;
}
.title {
color: #fff;
padding: 5px;
font-size: 20px;
font-weight: 500;
text-align: center;
margin-top: 8px;
margin-bottom: 8px;
}
.cell {
font-size: 17px;
font-weight: normal;
text-align: center;
margin-bottom: 9px;
margin-top: 9px;
}
.refund {
font-size: 14px;
line-height: 22px;
font-weight: normal;
text-align: left;
}
.button {
transition: all 100ms ease-in;
/**doubtful in emails**/
background: #375e97;
border-radius: 8px;
font-family: Helvetica, Arial, sans-serif;
font-size: 16px;
text-decoration: none;
display: block;
color: #ffffff;
text-align: center;
}
.button:hover {
transition: all 100ms ease-in;
/**doubtful in emails**/
background: #555;
border-radius: 8px;
font-family: Helvetica, Arial, sans-serif;
font-size: 16px;
text-decoration: none;
display: block;
color: #ffffff;
text-align: center;
}
<html lang="en">
<head>
<title>Multifamily Texas – Early Bird Registration</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://interfaceconferencegroup.com/mftx18/images/MFTX.css">
</head>
<body>
<div class="container3">
<h2>ACT NOW and SAVE $80!</h2>
<p class="subhead">Early Bird Registration is $279 through August 17th</p>
</div>
<div class="container4">
<table align="center" width="600" border="1" bordercolor="#375e97" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#375e97" align="center" colspan="2">
<p class="title">Early Bird Registration Pricing</p>
</td>
</tr>
<tr>
<td width="50%">
<p class="cell">Single Attendee</p>
</td>
<td width="50%">
<p class="cell">$279</p>
</td>
</tr>
<tr>
<td width="50%" bgcolor="#d3daee">
<p class="cell">Two Attendees</p>
</td>
<td width="50%" bgcolor="#d3daee">
<p class="cell">$568</p>
</td>
</tr>
<tr>
<td width="50%">
<p class="cell">Three Attendees</p>
</td>
<td width="50%">
<p class="cell">$857</p>
</td>
</tr>
<tr>
<td width="50%" bgcolor="#d3daee">
<p class="cell">Four Attendees</p>
</td>
<td width="50%" bgcolor="#d3daee">
<p class="cell">$1146</p>
</td>
</tr>
<tr>
<td width="50%">
<p class="cell">Five Attendees</p>
</td>
<td width="50%">
<p class="cell">$1435</p>
</td>
</tr>
<tr>
<td width="50%" bgcolor="#d3daee">
<p class="cell">Six Attendees</p>
</td>
<td width="50%" bgcolor="#d3daee">
<p class="cell">$1724</p>
</td>
</tr>
</table>
</div>
<div class="container">
<h3>Refund Policy</h3>
<p class="refund"><b>InterFace Conference Group/France Media, Inc. Cancellation Policy:</b> If you cancel your attendance 30 days or more before the conference, you will be issued a full refund. Within 30 days, you will be given a credit for the amount you paid. This
credit must be used within one year of the conference date to apply to another InterFace conference, for an equal or lesser amount.</p>
<p class="refund" align="center">InterFace Conference Group/France Media, Inc. Attendance & Substitution Policy and <a href="https://custom.cvent.com/7C0825B3546540A3BA33AF202D8A465F/files/4c106328c8e140e4b66ba30f4659af92.docx"
target="_blank">Privacy Policy</a></p>
</div>
</body>
</html>
It's because of the <h2>'s margin-top not being removed. Update this rule:
h2 {
color: #fff;
font-family: Minion Pro, Times New Roman, serif;
font-size: 42px;
font-weight: 700;
font-style: italic;
text-align: center;
padding-top: 25px;
margin-bottom: 15px;
margin-top: 0; /* This one */
}
Preview

how to show two different font size ,2 different texts using html,css

1st text part has two lines. 2nd text line has only one line. Here, I attached the image:
How do I do this using css?
<td class="right-col">
<div>
<div>
<span>average<br>cost</span>
</div>
<div>
<span>$2,500</span>
</div>
</div>
</td>
Try to this way
define class on your div and some write css according to your design.
.mainDiv{
padding: 20px;
background: #fcfcfc;}
.left-text {
display: inline-block;
vertical-align: top;
text-align: right;
color: gray;
text-transform: uppercase;
font-size: 11px;
line-height: 13px;
}
.right-text {
display: inline-block;
vertical-align: top;
text-align: right;
color: gray;
text-transform: uppercase;
font-size: 23px;
margin-left: 5px;
}
<div class="mainDiv">
<div class="left-text">
<span>average<br>cost</span>
</div>
<div class="right-text">
<span>$2,500</span>
</div>
</div>
One of the many ways you can do this.
.container {
width: 200px;
background: #E0E0E0;
font-size: 0;
font-family: sans-serif, serif;
padding: 20px;
}
.column {
color: #757575;
font-size: 16px;
display: inline-block;
width: 50%;
padding: 10px;
box-sizing: border-box;
vertical-align: middle;
}
.txt-left {
text-align: left;
font-size: 24px;
}
.txt-right {
font-size: 12px;
text-align: right;
}
<div class="container">
<div class="column txt-right">
<span>AVERAGE<br>COST</span>
</div>
<div class=" column txt-left">
<span>$2,500</span>
</div>
</div>
.right-col div {
table-layout: fixed;
font-family: Arial, sans-serif;
text-transform: uppercase;
background: linear-gradient(to bottom, #f7f8f8 0%,#fbfbfb 56%,#f5f6f6 74%,#e8e9e9 100%);
line-height: 10px;
font-size: 10px;
color: #85929c;
display: table;
width: 200px;
}
.right-col div span {
vertical-align: top;
display: table-cell;
padding: 10px 3px;
}
.right-col .text {
text-align: right;
}
.right-col .amount {
line-height: 20px;
font-size: 18px;
}
<table class="table">
<tbody>
<tr>
<td class="right-col">
<div>
<span class="text">average<br>cost</span>
<span class="amount">$2,500</span>
</div>
</td>
</tr>
</tbody>
</table>

Align multiple formats of text onto rows

The goal is to get the Kanji, English, and Kana rows of text lined up with each other into a specific format. Such that the text is largely interchangeable and isn't hard-coded.
The Kanji and English should be evenly placed next to each other. The Kana should be aligned with the top of the second row.
It was working before, but it was hard-coded, I commented out those regions.
It should look like this:
body {
height: 100%;
padding: 0;
margin: 0;
font-size: 60%;
font-family: Verdana,sans-serif;
word-break: break-all;
}
#header {
padding-top: 10px;
width:100%;
height:286px;
padding-top: 20px;
}
#kanjiTransl{
display: inline-block;
font-size: 5.5em;
font-weight: bold;
/*position: absolute;*/
/*left: 25px;*/
/*top:15px;*/
line-height: 1.1em;
}
#jaN {
margin-bottom: 5px;
}
#kana {
display: inline-block;
vertical-align: top;
color: #777;
/*position: inline;*/
/*right: 30px;*/
/*top:130px;*/
/*font-size: 1.4em;*/
}
.top {
letter-spacing: -0.07em;
}
.bottom {
letter-spacing: -0.02em;
/*margin-left: 12px;*/
}
.topColor {
/*color: #FF2EDF;
color: #84FF00;
color: #b4FF00;*/
color: #a78317;
color: #908090;
}
.bottomColor {
/*color: #84FF00;
color: #FF2EDF;
color: #dc3616;*/
color: #9f3420;
color: #222266;
}
.headerItem {
display: inline-block;
/*height:110px;*/
/*width:900px;*/
/*position: relative;*/
/*left:.6em;*/
/*line-height: 110px;*/
font-size:15em;
font-weight:900;
}
<body>
<div id="header">
<div id="kanjiTransl">
<span id="jaN" class="topColor">驚<br>的<br></span>
<span id="jaV" class="bottomColor">速<br>記</span>
</div>
<span class="headerItem top topColor">LARGE</span><br>
<span class="headerItem bottom bottomColor">WARNING</span>
<span id="kana">ノテイショナルヴェロシティ</span>
</div>
</body>
Use this Layout and tune it to your needs:
#header {
padding-top: 10px;
width: 100%;
height: 286px;
width: 850px;
}
#jaN,
#jaV {
font-size: 5.5em;
font-weight: bold;
line-height: 1.1em;
vertical-align: top;
color: #777;
}
#kana {
float: right;
}
.top,
.bottom {
vertical-align: top;
font-weight: 900;
}
.top {
letter-spacing: -0.07em;
color: #908090;
font-size: 15em;
line-height: 0.3em;
}
.bottom {
letter-spacing: -0.02em;
font-size: 10em;
line-height: 0.3em;
color: #222266;
}
<table id="header">
<tr>
<td id="jaN">驚
<br>的</td>
<td>
<span class="top">NATIONAL</span>
</td>
</tr>
<tr>
<td id="jaV">速
<br>記</td>
<td>
<span class="bottom">VELOCITY</span>
<span id="kana">ノテイショナルヴェロシティ</span>
</td>
</tr>
</table>