How can I get this image done in HTML and CSS? - html

I have this image that is to be implemented in HTML and CSS.
This is what I have tried.
<span>$</span><span style="font-size: 50px;">99</span><span style="vertical-align: text-top;">00</span>
But this actually doesn't turn out like I want in the image.

For example:
.price {
font-size: 80px;
color: #f60;
}
.price sup {
font-size: 38px;
}
.price sub {
font-size: 28px;
color: #aaa;
position: absolute;
display: inline-block;
margin: 48px 0 0 -40px;
}
<span class="price"><sup>$</sup>99<sup>00</sup><sub>/month</sub></span>
http://jsfiddle.net/1zjuddj8

It sounds like the <sup> tag is your friend here. Any text in the <sup> tags will become superscript.
Example
<sup>$</sup>99<sup>00</sup>
Additional Documentation/Reference from w3.org: http://www.w3.org/TR/html-markup/sup.html

You have a specific tag for make your text appears on the top use <sup></sup> to treat it like an indice and <sub></sub> as a note. To force the alignement you will have to play with vertical-align value in px or in %.
`
<sup style="vertical-align: 10;">$</sup><sub style="font-size: 50px;vertical-align:-10">99</sub><sup style="vertical-align: 10;">00</sup>

You can use sup to make the text superscript and then set the position of the text using position: relative and top:
HTML:
<h1><sup>$</sup>99<sup>00</sup></h1>
CSS:
h1 { font-size: 50px; }
sup { font-size: 15px;
position: relative;
line-height: 0;
vertical-align: baseline;
top: -23px;
}
JS Fiddle

A solution which requires a bit more fine tuning, but has a lot of control, very useful for front-end layouts:
HTML code
<div class="price_tag">
<div class="price"><sup>$</sup><span class="bignum">99</span><sup>00</sup>
</div>
<div class="month">/month</div>
</div>
CSS code
.price_tag {
position:relative;
width:190px;
height:100px;
color:#f90;
font-size:6em;
font-family:helvetica, arial, sans-serif;
}
.price {
position:relative;
width:200px;
height:100px;
font-weight:bold;
}
sup {
position:relative;
font-size:2.5rem;
top:1rem
}
.month {
width:60px;
height:30px;
color:#ccc;
font-size:1rem;
right:0;
bottom:0;
z-index:3;
position:absolute;
}
fiddle here

To duplicate it with accuracy, your code will have to be more involved than that. I've tried to match it as closely as I could here: http://jsfiddle.net/wvcm92ka/
The code is below:
HTML:
<div class="amount">
<div class="amount-parts">
<div class="amount-currency">$</div>
<div class="amount-whole">99</div>
<div style="clear: left;"></div>
</div>
<div class="amount-parts">
<div class="amount-decimal">00</div>
<div class="amount-period">/month</div>
<div style="clear: left;"></div>
</div>
<div style="clear: left;"></div>
</div>
CSS:
.amount-parts{
font-family: verdana, sans-serif;
float: left;
}
.amount-currency, .amount-whole, .amount-decimal, .amount-period{
font-weight: 600;
}
.amount-currency, .amount-whole, .amount-decimal{
color: #ff0000;
}
.amount-currency{
float: left;
font-size: 32pt;
font-weight: bold;
margin-top: 5px;
}
.amount-whole{
font-size: 60pt;
float: left;
}
.amount-decimal{
color: #ff0000;
font-size: 24pt;
font-weight: bold;
margin-top: 15px;
}
.amount-period{
color: #999;
font-size: 10pt;
font-weight: bold;
}

Another solution:
body {
font-size: 20px;
}
.div-table {
display: table;
border-collapse: collapse;
}
.div-table .div-table-row {
display: table-row;
}
.div-table .div-table-cell {
display: table-cell;
text-align: left;
vertical-align: top;
}
.big-number {
font-size: 50px;
}
.padding-top {
padding-top: 5px;
}
<div class="div-table">
<div class="div-table-row">
<div class="div-table-cell padding-top">
$
</div>
<div class="div-table-cell">
<span class="big-number">99</span>
</div>
<div class="div-table-cell padding-top">
<div>00</div>
<div>/month</div>
</div>
</div>
</div>
http://jsfiddle.net/gbx0ogqm/

Related

How do I put one <div> element below another <div>

I just finished doing HTML/CSS with Codecademy. One of the "projects" there is to make your own resume. I took the HTML/CSS from that project, and I'm tweaking it to make the resume look better. I'm currently trying to put one div - the part of the resume where text about my career objective will go - under another div, the header. It is, however, not working. The div for the "objective" is currently behind the div for the header. How on earth do I get that second div for the objective to go underneath the first div?
I read something about how I should float the header div to the left and then put clear:both; in the div for the objective, but that's not working.
HTML
<div id="header">
<p id="name">My Name</p>
<p id="email">myemail#email.com</p>
</div>
<div id="objective"></div>
<div class="left"></div>
<div class="right"></div>
<div id="footer">
<p>1234 Anywhere Street, Brooklyn NY 11216 | Tel: (123) 456-7890</p>
</div>
CSS
div {
border-radius: 5px;
}
#header {
z-index:1;
position: fixed;
width: 98%;
margin-top: -20px;
height: 60px;
background-color: #668284;
margin-bottom: 10px;
float:left;
}
#name {
float:left;
margin-left: 5px;
padding-top: 5px;
font-size: 16px;
font-family: Verdana, sans-serif;
color: #ffffff;
}
#email{
float:right;
margin-right: 5px;
padding-top: 5px;
font-size: 16px;
font-family: Verdana, sans-serif;
color: #ffffff;
}
.right p {
margin-left: 5px;
margin-right: 5px;
margin-top: -10px;
font-family: Garamond, serif;
color: #000000;
}
a:hover {
font-weight: bold;
}
#objective {
height: 50px;
background-color: #668284;
font-family: Verdana, sans-serif;
font-size: 14px;
text-align: center;
clear:both;
color: #ffffff;
}
.left {
position: relative;
float: left;
margin-top: 50px;
width: 49%;
height: 400px;
background-color: #B9D7D9;
margin-bottom: 10px;
}
.right {
position: relative;
float: right;
margin-top: 50px;
width: 49%;
height: 400px;
background-color: #F4EBC3;
margin-bottom: 10px;
}
#footer {
position: relative;
height: 50px;
background-color: #668284;
clear: both;
font-family: Verdana, sans-serif;
font-size: 14px;
text-align: center;
color: #ffffff;
}
#footer p {
position: relative;
padding-top: 15px;
}
For example:
<div class="div1">KSD;JSFAJ;SSD;</div>
<div class="div2">KSD;JSFAJ;SSdfaD;</div>
Css with float:
.div1 {
float: none;
}
.div2 {
float: none;
}
Css with display:
.div1 {
display: inline;
}
.div2 {
display: inline;
}
Here is the updated HTML :
<div id="header">
<p id="name">My Name</p>
<p id="email">myemail#email.com</p>
</div>
<div style="height:50px;width:98%;">
</div>
<div id="objective">Objective goes here</div>
<div class="left"></div>
<div class="right"></div>
<div id="footer">
<p>1234 Anywhere Street, Brooklyn NY 11216 | Tel: (123) 456-7890</p>
</div>
This will show the objective div underneath header div.
Also this is a link for your reference.
Here is update CSS, This show the responsive your html
*{
padding: 0;
margin: 0;
box-sizing: border-box;
}
div {
border-radius: 5px;
}
#header {
width: 98%;
margin: 0 auto;
height: 60px;
background-color: #668284;
margin-bottom: 10px;
}
#name {
float:left;
margin-left: 5px;
padding-top: 5px;
font-size: 16px;
font-family: Verdana, sans-serif;
color: #ffffff;
}
#email{
float:right;
margin-right: 5px;
padding-top: 5px;
font-size: 16px;
font-family: Verdana, sans-serif;
color: #ffffff;
}
.right p {
margin-left: 5px;
margin-right: 5px;
margin-top: -10px;
font-family: Garamond, serif;
color: #000000;
}
a:hover {
font-weight: bold;
}
#objective {
height: 50px;
background-color: #668284;
font-family: Verdana, sans-serif;
font-size: 14px;
text-align: center;
clear:both;
color: #ffffff;
}
.left {
position: relative;
float: left;
margin-top: 50px;
width: 49%;
height: 400px;
background-color: #B9D7D9;
margin-bottom: 10px;
}
.right {
position: relative;
float: right;
margin-top: 50px;
width: 49%;
height: 400px;
background-color: #F4EBC3;
margin-bottom: 10px;
}
#footer {
position: relative;
height: 50px;
background-color: #668284;
clear: both;
font-family: Verdana, sans-serif;
font-size: 14px;
text-align: center;
color: #ffffff;
}
#footer p {
position: relative;
padding-top: 15px;
}
Don't ever forget to add this code
*{
padding: 0;
margin: 0;
box-sizing: border-box;
}
So that you won't have empty space on your div
DEMO
I think its easier using bootstrap, here is the link http://getbootstrap.com/css/
What bootstrap does is that it creates containers that wrap the content of your site. It divides the site in rows. To do that you need and . With this bootstrap you can divide your rows in 12 cells.
Here is an example of how I divided my portfolio in 3 columns of 4 spaces
<div class="row">
<div class="col-md-12">
<hr>
</div>
</div>
<div class="row text-center">
<div class="col-md-4">
<h3 class="text-body"><u>Block vs Inline</u>
</h3>
<p class="p-text"><span>Block Elements</span> are those who take the complete line and full width of the page creating a "box".<br>
<span>Inline Elements</span> are those who doesn´t affect the layout, just the element inside the tag.
</p>
</div>
<div class="col-md-4">
<h3 class="text-body"><u>Selectors</u></h3>
<p class="p-text"><span>Class selectors</span> are used to target elements with specific attributes<br>On the other hand, <span>id selectors</span> are just for unique elements.</p>
</div>
<div class="col-md-4">
<h3 class="text-body"><u>Responsive Layout</u></h3>
<p class="p-text"><span>Responsive Layout</span> is the combination of html and css design to make the website look good in terms of enlargement, shrink and width in any screen (<em>computers, laptops, netbooks, tablets, phones</em>). </p>
</div>
</div>

Can't get div to overlay another div containing a canvas

Html looks like this:
<div id="content">
<div id="menu">
<img src="GFX/logo.png" class="centeredImage" />
<div class="menuItem">Play</div>
</div>
<div id="gameOver">
<div class="menuItem" id="finalScore"></div>
</div>
<div id="game">
<div style="float:left; width:600px">
<canvas id="canvas" width="600" height="900" style="">
Your browser doesn't appear to support the HTML5 <canvas> element.
</canvas>
</div>
<div id="info">
<img src="GFX/logo.png" id="logo" />
<div class="desciptor">Multiplier:</div>
<div id="multi" class="info"> 12</div>
<div class="desciptor">Score:</div>
<div id="score" class="info">452343</div>
<div class="desciptor">Level:</div>
<div id="level" class="info">466</div>
</div>
</div>
</div>
And this is the CSS:
body
{
background-color: black;
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
font-size: 24px;
}
#content
{
width:900px;
display: block;
margin-left: auto;
margin-right: auto;
text-align: center;
}
#info
{
float:right;
width:260px;
height:860px;
background-color:#0f0f0f;
color:white;
padding:20px;
text-align:center;
}
#menu
{
display:block;
}
#game
{
display:block;
position:relative;
}
#logo
{
margin: -20px;
}
.centeredImage
{
display:block;
margin:auto;
}
.menuItem
{
padding-top:30px;
font-size:6em;
text-align:center;
}
a:link {text-decoration: none; color: white;}
a:visited {text-decoration: none; color: white;}
a:active {text-decoration: none; color: white;}
a:hover {text-decoration: none; color: white;}
.desciptor
{
padding-top:30px;
font-size:0.7em;
text-align:left;
width:inherit;
}
.info
{
width:inherit;
}
#multi {
font-size: 4em;
}
#score
{
font-size:2em;
}
#level
{
font-size:1.5em;
}
#gameOver
{
color: white;
position: absolute;
display:block;
padding-top:30px;
font-size:6em;
text-align:center;
height: 870px;
margin-top: -900px;
z-index: 999;
}
What I'm trying to achieve is to have the gameOver div overlay the game div and its content. Unfortunately this doesn't work as I do it. Any ideas ?
I'm not too sure about the display and position attributes and how they affect overlaying of divs.
Looks to me like you're trying to use two different methods simultaneously.
Using position:absolute attribute already causes your #gameOver div to set position independently of other blocks except for parenting. http://www.w3schools.com/cssref/pr_class_position.asp
You're trying to make one block overlap another with negative margin (but setting negative-margin to the wrong element)
This results in your #gameOver div to rest on top of your page (provided there's some content in #finalScore block)
To resolve your issue, do either one of the following:
Delete margin-top property from #gameOver
#gameOver {
color: white;
display: block;
font-size: 6em;
height: 870px;
margin-top: -900px;
padding-top: 30px;
position: absolute;
text-align: center;
z-index: 999;
}
Remove position: absolute; and margin-top: -900px; properties from #gameOver element and add margin-top: -900px; to your #game div. So your css will look like this:
#gameOver {
color: white;
display: block;
font-size: 6em;
height: 870px;
padding-top: 30px;
text-align: center;
z-index: 999;
}
#game {
display: block;
margin-top: -900px;
position: relative;
z-index: -1;
}

Figuring out CSS for a three column layout with header [sketch included]

I'm using this CSS track to get the hang of what's happening in the browser. However, the last assignment was an incomplete success. How can I push the post-updates section not only right, but to the top of the page?. (So far I've tried position: absolute without much luck).
ed: Both answers helped, I am grateful.
You can try this:
Working Fiddle here
#post-update {
position:absolute;
top:0; right:0;
}
Good Luck...
The <div id="post-update"> needs to be floated right and the width of the header narrowed to fit in the screen.
JSFiddle Demo
HTML
<div id="content">
<div id="header">
<h1 id="stf">Stanford Connection</h1>
<img src="//i62.tinypic.com/i2onyf.gif" alt="I'm a tree"/>
</div>
<div id="about">
<img src="//i62.tinypic.com/2vnkmtl.jpg" alt="Molly"/>
<h2 class="section-heading">About Me</h2>
<p><strong>Birthday:</strong> December 8, 2001</p>
<p><strong>Gender:</strong> Female</p>
<h2 class="section-heading">Friends</h2>
<p><strong>Patrick Young</strong></p>
<p><strong>Chloe Cox</strong></p>
</div>
<div id="updates">
<h1>Molly the FloPup</h1>
<h2 class="section-heading">Status Updates</h2>
<p>When am I going to get fed?</p>
<p>I want to go for a walk. </p>
<p>There's a squirrel on the patio, why won't Patrick let me chase it? </p>
<p>I really like summer, because I get to sun myself on the patio </p>
</div>
</div>
<div id="post-update">
<h2 class="section-heading">Post Updates</h2>
<form action="">
<textarea name="" id="" cols="30" rows="10"></textarea>
<br>
<input type="button" value="Submit New Update" align="left"/>
</form>
</div>
CSS
body {
padding: 0.5em;
}
strong {
font-weight: bold;
}
h1 {
font-size: 32pt;
text-indent: 1em;
padding-top: 0.3em;
padding-bottom: 0.3em;
}
#stf {
margin-left:1em;
line-height: 2.5em;
display: inline;
vertical-align: top;
}
#content {
width:50em;
float:left;
}
#header {
background-color: #9A0000;
color: white;
height: 120px;
}
#header img {
display: inline;
vertical-align: top;
float: right;
}
.section-heading {
border-top: 3px solid black;
border-bottom: 3px solid black;
background-color: #CC9191;
font-size: 13pt;
padding-left: 0.5em;
padding-bottom: 0.3em;
padding-top: 0.3em;
margin-bottom: 0.5em;
margin-top: 0.5em;
}
#about {
width: 200px;
font-family: sans-serif;
font-size: 12pt;
float: left;
}
#about img {
margin-top: 7px;
}
#updates {
/* background: #AA4; */
float:left;
margin-left:10px;
}
#updates p {
border-top: 2px solid black;
line-height: 2em;
}
#post-update {
float: right;
}
textarea {
width: 17em;
height: 7em;
}

How do I center this element?

My HTML:
<div class="container">
<div class="card login">
<p id="Title">Plex</p>
<div class="label">
</div>
Random text
</div>
<div class="card welcome">
<div class="label">
<p id="Title">Hi!</p>
</div>
Lorem ipsum
</div>
<div class="card extra">
<div class="label">
<p id="Title">Extra</p>
</div>
Lorem ipsum
</div>
</div>
MY CSS:
.container{
display: flex;
width: 100%;
/*align-content: center;*/
}
.card {
flex: 1 1 auto;
border: 1px solid #f3f3f3;
background-color: #f3f3f3;
margin-left: 50px;
margin-right: 50px;
margin-top: 25px;
height: 450px;
}
.label{
background-color: #434342;
width:auto;
height: 70px;
}
.card:not(:first-child){
margin-left: 20px;
}
#Title {
float: left;
font-family: Thinfont-Thin;
font-size: 42px;
color: #d2731d;
text-align: center;
}
A JSFiddle: http://jsfiddle.net/cvYGW/
How do I make the PLEX HI EXTRA all align perfectly in the middle of their cards and how do I move them up or down?
You have to reset margin to 0 for #title and put a line-height that equals to the height of the parent.
#title { /* change this selector to .title */
line-height: 70px;
margin: 0;
font-family: Thinfont-Thin;
font-size: 42px;
color: #d2731d;
text-align: center;
}
See: http://jsfiddle.net/cvYGW/9/
By the way, remember that your code is not valid HTML, as you use the same ID three times (#title). You should use class in this case. And you don't need any float property.
You shouldn't have multiple instances of an ID, so firstly change #Title to a class
You can't use float:left; & text-align:center;, remove the margin from your title p, match the line height
.title {
margin:0px;
line-height:70px;
font-family: Thinfont-Thin;
font-size: 42px;
color: #d2731d;
text-align: center;
}
http://jsfiddle.net/cvYGW/6/
#Title {
font-family: Thinfont-Thin;
font-size: 42px;
color: #d2731d;
text-align: center;
margin:0 auto;
}
I have update the js fiddle
you just have to add
#Title {
line-height:70px;
width:100%;
margin:0;
}
Check on fiddle
Please refer below updated fiddle
http://jsfiddle.net/cvYGW/10/
give some width for parent div and align the child elements in center of parent by using margin css property.
margin: 0 auto;
Thanks,
Siva
Check out http://jsfiddle.net/skyrbe/cvYGW/8/
You were using same id for multiple p tags . Never do that.
.Title {
float: left;
font-family: Thinfont-Thin;
font-size: 42px;
color: #d2731d;
text-align: center;
width:100%;
margin:0px auto;
line-height:42px;
}
update css:
#Title {
float: left;
font-family: Thinfont-Thin;
font-size: 20px;
color: #d2731d;
text-align: center;
width: 100%;
}
jquery animation
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$('#Title').click(function(){
$('#Title').animate({
bottom: '-=20'
}, 1000);
});
});
updated fiddle

How to put an image next to each other

I'm trying to put these two 'hyperlinked' icons next to each other but I can't seem to do that. As you can see, the twitter icon falls to the next line.. (they are both hyperlinked to their respective website)
HTML
<div class="nav3" style="height:705px;">
<div id="icons"><img src="images/facebook.png">
</div>
<div id="icons"><img src="images/twitter.png">
</div>
</div>
CSS
.nav3 {
background-color: #E9E8C7;
height: auto;
width: 150px;
float: left;
padding-left: 20px;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #333333;
padding-top: 20px;
padding-right: 20px;
}
#icons{position:relative;
width: 64px;
height: 64px;
}
#icons a:hover {
background: #C93;
display: block;
}
How do I make the aligned next to each other?
Thanks in advance
You don't need the div's.
HTML:
<div class="nav3" style="height:705px;">
<img src="images/facebook.png">
<img src="images/twitter.png">
</div>
CSS:
.nav3 {
background-color: #E9E8C7;
height: auto;
width: 150px;
float: left;
padding-left: 20px;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #333333;
padding-top: 20px;
padding-right: 20px;
}
.icons{
display:inline-block;
width: 64px;
height: 64px;
}
a.icons:hover {
background: #C93;
}
See this fiddle
Change div to span. And space the icons using
HTML
<div class="nav3" style="height:705px;">
<span class="icons"><img src="images/facebook.png">
</span>
<span class="icons"><img src="images/twitter.png">
</span>
</div>
CSS
.nav3 {
background-color: #E9E8C7;
height: auto;
width: 150px;
float: left;
padding-left: 20px;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #333333;
padding-top: 20px;
padding-right: 20px;
}
.icons{
display:inline-block;
width: 64px;
height: 64px;
}
a.icons:hover {
background: #C93;
}
span does not break line, div does.
Check this out. Just use float and get rid of relative.
http://jsfiddle.net/JhpRk/
#icons{float:left;}
try putting both images next to each other. Like this:
<div id="icons"><img src="images/facebook.png"><img src="images/twitter.png">
</div>
Instead of using position:relative in #icons, you could just take that away and maybe add a z-index or something so the picture won't get covered up. Hope this helps.