How to stack smaller text in CSS? - css

I have this little bit of text on my page:
I need to place the month (DEC) on top of the year (2013). How can I do this with CSS?
Using BR, or floats, seems to lead to all kinds of crazy formatting problems. Obviously, as the date changes, so does the width, so I can't lock it into a fixed width.
What I have so far:
html
<span class='month'>DEC</span><span class='year'>2013</span>
css
margin-left:20px;
position:relative;
top:-12px;
padding:12px 20px;
font-size:18px;
text-align:right;

Check this one, DEMO http://jsfiddle.net/yeyene/VPZgV/2/
HTML
<div class="day">
<span class="date">31</span>
<div class="mth_yr">
<span class='month'>DEC</span>
<span class='year'>2013</span>
</div>
</div>
CSS
.day{
float:left;
padding:10px;
background:#F0EAE9;
font-family:Georgia, "Times New Roman", Times, serif;
}
.date{
float:left;
padding:8px 10px 2px 10px;
border-right:3px solid #fff;
font-size:30px;
font-weight:bold;
height:50px;
background:#E9A3A0;
color:#fff;
}
.mth_yr{
float:left;
width:35px;
height:50px;
padding:10px 10px 0px 10px;
background:#E9A3A0;
color:#fff;
}

Related

How to set label and input in one line?

Hi i have a diferent style because betwin labale and input set icon. Please lock at the https://jsfiddle.net/mL1o0d5m/
css codes :
body{
font-family: tahoma;
font-size:14px;
background-color:#f1f1f1;
color:#999;
direction:rtl;
}
.form{
font-size:14px;
width:100%;
}
.form label{
text-align: right;
clear: both;
float:right;
}
.form input.inputs{
font-size:14px;
color:#999;
display:block;
border:1px solid #ccc;
border-right:none;
background-color:#fff;
width:80%;
margin-bottom:20px;
padding:10px;
padding-right:30px;
box-sizing:border-box;
-webkit-box-sizing:border-box;
-moz-box-sizing:border-box;
box-shadow:none;
-webkit-appearance: none;
}
.addon{
position:relative;
font-size:0;
}
.addon:before{
display:block;
content:"";
width:3px;
height:100%;
background-color:#3399cc;
position:absolute;
}
.icon:before{
font-size:14px;
color:#bbb;
position:absolute;
top:12px;
right:12px;
}
HTML :
<form class="form">
<label>Name</label>
<div class="addon">
<i class="icon fa fa-user"></i>
<input class="inputs" name="name" type="text" placeholder="Name" />
</div>
</form>
I wanna to set label and input in same line .label should be in right and input and icon must be at left .
Thanks .
like this? https://jsfiddle.net/mL1o0d5m/1/ it is one of the many posibilities to achieve this. Added some css
.form > label{
text-align: right;
float:right;
width:40px;
margin-top:10px;
}and also to .icon:before and .addon:beforeSee in fiddle

CSS Links Float IE7 or less

Following CSS - works fine in IE8 or greate but not for IE7 or less:
#main_navi {
list-style:none;
text-align:left;
padding:0px;
margin:0px 0px 20px 0px;
float:left;
}
.dsn li {
display: none;
}
a.main_navi_0 ul {
float:left;
display:none;
}
a.main_navi_0:link, a.main_navi_0:visited {
color:blue;
font-size:16px;
font-weight:200;
font-family: 'Allerta', sans-serif;
height:65px;
padding:40px 10px 0 20px;
display:block;
float:left;
text-align:center;
}
a.main_navi_1:link, a.main_navi_1:visited {
font-size:16px;
font-weight:200;
font-family: 'Allerta', sans-serif;
height:65px;
padding:40px 10px 0 20px;
display:block;
float:left;
text-align:center;
color: #3c94e2;
}
a.main_navi_0:hover, a.main_navi_1:hover {
color:#000;
border-bottom:5px solid #3c94e2;
}
a.sub_navi_0:link, a.sub_navi_0:visited {
color:#696969;
font-size:13px;
font-weight:200;
font-family: 'Allerta', sans-serif;
height:25px;
padding:5px 10px 0 10px;
display:block;
float:left;
text-align:center;
z-index:999;
position:relative;
border-bottom:2px solid #dedad6;
}
a.sub_navi_1:link, a.sub_navi_1:visited {
color:#696969;
font-size:13px;
font-weight:200;
font-family: 'Allerta', sans-serif;
height:25px;
padding:5px 10px 0 10px;
display:block;
float:left;
text-align:center;
z-index:999;
position:relative;
border-bottom:2px solid #3c94e2;
}
a.sub_navi_0:hover, a.sub_navi_1:hover {
color:#000;
border-bottom:2px solid #3c94e2;
}
MY html-file:
<div id="nav">
<div id="logo">
<a target="_self" href="fileadmin/../home.html">
<img border="0" title="4fleet Group" alt="" src="fileadmin/../fileadmin/img/logo.jpg">
</a>
</div>
<div id="main_navi">
<ul>
<li class="dsn">
<a class="main_navi_0" href="xyz.html">Über uns</a>
<ul>
<li>
<a class="sub_navi_0" href="xyz/team.html">Team</a>
</li>
<li>
<a class="sub_navi_0" href="xyz/presse.html">Presse</a>
</li>
</ul>
</li>
*another li with class ="dsn" tree*
</ul>
</div>
My output in IE7 or less than IE7:
Link1
Link2
Link3
I want it that way:
Link1 Link2 Link3
How do I get it to work in IE7. I do have an extra CSS file for IE7. I just don't know the code in CSS.
inline-block; is not a valid value for float
I guess you meant display: inline-block;. This won't work in IE7 though.
What you probably want is float: left; but it's hard to say without seeing any HTML.

css dialox box to html li item

how can I have kinda like dialog boxes besite the bullet of a li element?
<div class="contentContenedor">
<div class="tituloContentContenedor">Box: Promociones nacionales</div>
<div class="linksContentContenedor">
<ul>
<li>
<span>Vuela barato por Chile</span>
<span class="linksContentContenedorClicks" style="background-color:blue; color:white; float:right; padding:0px 4px 0px 4px">612</span>
</li>
<li>
<span>Encántate con el sur de nuestro país</span>
<span class="linksContentContenedorClicks" style="background-color:blue; color:white; float:right; padding:0px 4px 0px 4px">102</span>
</li>
<li>
<span>Disfruta el norte de Chile</span>
<span class="linksContentContenedorClicks" style="background-color:blue; color:white; float:right; padding:0px 4px 0px 4px">64</span>
</li>
<li>
<span>Canjea tus kms. y vuela por Chile</span>
<span class="linksContentContenedorClicks" style="background-color:blue; color:white; float:right; padding:0px 4px 0px 4px">49</span>
</li>
</ul>
</div>
</div>
(I can change de order of the span, or put the info outside the li)
CSS:
.contentContenedor{
background-image:url('img/fondo_cajas_home.gif');
background-repeat:no-repeat;
background-position:center bottom;
width:270px;
height:140px;
}
.tituloContentContenedor{
background-image:url('img/fondo_tit_cajas_home_270_23.gif');
background-repeat:no-repeat;
width:270px;
height:23px;
color:white;
font:bold 11px Arial,Helvetica,sans-serif;
padding:6px 0px 2px 11px;
}
.linksContentContenedor{
font-size:12px;
text-decoration:underline;
color:#0267C3;
}
.linksContentContenedor ul{
padding:0;
margin:0;
margin-left:28px;
padding-bottom:10px;
}
.linksContentContenedor li span{
position:relative;
left:-5px;
}
.linksContentContenedorClicks{
position:absolute;
left:10px;
}
I'm able tu add a square with info beside de li element but it stays inside de container.
I'd like it to be like:
but for each li element and always pointing to the bullet.
what complicates me the most is that im not able to get the info outside the container.
if I add absolute position then I wouldnt know the left and top margins since, this boxes are php created.
PS: it is not a tooltip, kinda looks like it but it has to be always present, not when hovering or whatever.
thsnk youuu!
Here is what I did,
.info {
position: absolute;
right: 115%;
width: 60px;
height: 40px;
background: #c1c1c1;
text-align: center;
}
.info:before {
content: "";
height: 0;
width: 0;
position: absolute;
left: 100%;
border-left: 15px solid #c1c1c1;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
This css will make the "info box" you are looking for. This is just a start so you can tweek it in anyway you want. If you are looking for just a border and not solid color then I would advice you to use an image. It could be possible I believe but not very effect/supported.
Here is the JSFIDDLE with the rest of css. Just make sure the li containing the .info is position: realtive;.

CSS Issue with float:left; and main container

I've come across a bit of an issue and was hoping for some advice.
I've always been a bit on-off with laying out websites like this but it's come to the day where I've had enough of fending it off.
So I have two divs, left and center, both are set to float:left; These are both in a "main" section but because the two are floating, the "main" section is smaller in height than these two which overlap due to the floating quality.
I've tried display:inline & display:inline-block but the first stacks them one on top of the other whilst the latter completely loses me my CSS for the corresponding div.
Was hoping someone could help me, if so, it'd be greatly appreciated! Here's the code:
HTML:
<div id="main_container">
<aside id="left">
<p id="settings_header">
Account Settings
</p>
<hr>
<img id="profile_picture" src="#" />
<div id="settings_option">
<a href="#">
Settings
</a>
</div>
<div id="settings_option">
<a href="#">
Sign Out
</a>
</div>
</aside>
<div id="center">
<h2>
Latest & Greatest Topics
</h2>
</div>
</div>
CSS:
#main_container {
width:82%;
min-width:932px;
margin-left:auto;
margin-right:auto;
padding:10px 10px;
box-shadow:inset 0 0 10px #000;
background-color:#ccc;
}
#left {
width:26%;
min-width:176.4px;
margin-right:5px;
display:inline-block;
float:left;
background-color:#fff;
border:1px solid #222;
box-shadow:0 0 5px #000;
font-family: verdana;
font-size:12px;
color: #000;
}
#center {
width:68%;
min-width:670.6px;
margin-left:5px;
margin-right:5px;
display:inline-block;
float:left;
background-color:#fff;
border:1px solid #222;
box-shadow:0 0 5px #000;
font-family: verdana;
font-size:12px;
color: #333;
text-align:left;
}
#center h2 {
font-family:tahoma;
font-weight:bold;
font-size:18px;
text-decoration:underline;
text-align:center;
color:black;
letter-spacing:1px;
}
Thanks for any help in advance!
You just need to add this:
#main_container:after {
content: "";
display: block;
clear: both;
}
Try this one:
#main_container {
float:left;
}
See the result
add
overflow:hidden
to #main
Because you have set width on your container everything should be kept in the box

HTML, CSS : Why does my layout mess up on different resolutions?

I am trying to make a portfolio kind of thing with HTML and CSS and my layout looks really good on my resolution of 1920 * 1080 but when i change the resolution everything moves around and everything looks really bad.
Can anybody point out to me where I am going wrong with my code and provide me with a solution to my problem?
--- Edited new code
How it looks on 1920 * 1080:
http://screencast.com/t/mq8H3baBxIi
So i have changed the advised things but i'm still getting that, for example, when i change from my screen resolution of 1920 * 1080 to 1280 * 1024 to test how it looks the comment areas pull on top of the grey 'contact me' box so that it ends up like me picture on this link:
http://screencast.com/t/xZEwSgwdqP
<html>
<head>
<link rel="stylesheet" type="text/css" href="portfolioStyles.css" />
</head>
<body>
<div id="pageTitleContact"> CONTACT ME</div>
<div id="sideBar"> </div>
<div id="commentSideBar"> </div>
<div id="logos">
<ul>
<div id="home"><li><img src="home.png" alt="list item 1" /></li></div>
<div id="aboutMe"><li><img src="aboutMe.png" alt="list item 2" /></li></div>
<div id="achievements"><li><img src="achievement.png" alt="list item 3" /></li></div>
<div id="hobbies"><li><img src="Hobbies.png" alt="list item 4" /></li></div>
<div id="contactMe"><li><img src="contactMeHighlighted.png" alt="list item 4" /></li></div>
</ul>
</div>
<textarea id="contactMeTextarea">
</textarea>
<div id="Commentsection">
<form action="postcommentandreturn.php" method="post">
<div id="nameAreaTitle">
Name:</div><input type="text" id="nameArea" name="name" />
<br>
<textarea placeholder="Insert Comment Here..." type="text" id="commentArea" name="comment"></textarea>
<div id="submitLocation"><input type="submit" id="submitComment" value="Submit"/></div>
</form>
</div>
<!--comment section-->
<div id="postedComments">
<tr>
<td><div id="postersName"> </div>
</td>
</tr>
<tr>
<td><div id="commentDate"></div></td>
</tr>
<tr>
<td>
<textarea id="postersComment"></textarea></td>
</tr>
</table>
</div>
</body>
</html>
css:
html,body
{
height: 100%;
padding: 0px;
margin: 0px;
}
#sideBar {
background-color: #111111;
width:100px;
height:100%;
position:fixed;
z-index:-1;
}
#commentSideBar {
background-color: #111111;
width:300px;
height:100%;
position:fixed;
z-index:-1;
right:0;
}
#logos {
position:absolute;
margin-left:-20px;
}
#home {
margin-top:50px;
}
#homeInfo {
resize: none;
position:fixed;
display: block;
height:400px;
width:800px;
overflow:hidden;
outline:none;
background-color:#3f3f3f;
color:white;
font-family:Arial;
font-size:30px;
border-radius:10px;
font-weight:700;
text-align:left;
padding-right:20px;
padding-left:40px;
top: 50%;
left: 50%;
max-width:800px;
margin-left:-350px;
margin-top:-200px;
-moz-box-shadow: 3px 3px 5px 6px #ccc;
-webkit-box-shadow: 3px 3px 5px 6px #ccc;
box-shadow: 3px 3px 5px 6px #ccc;
}
#pageTitleContact {
position:fixed;
top: 50%;
left: 50%;
margin-top:-400px;
margin-left:-400px;
color:limegreen;
font-size:100px;
font-family:Arial;
-moz-box-shadow: 3px 3px 5px 6px #ccc;
-webkit-box-shadow: 3px 3px 5px 6px #ccc;
box-shadow: 3px 3px 5px 6px #ccc;
padding-left:20px;
padding-right:20px;
}
#aboutMe {
margin-top:100px;
}
#achievements {
margin-top:100px;
margin-left:-7px;
}
#hobbies {
margin-top:100px;
}
#contactMe {
margin-top:100px;
margin-bottom:50px;
}
#contactMeTextarea {
-moz-box-shadow: 3px 3px 5px 6px #ccc;
-webkit-box-shadow: 3px 3px 5px 6px #ccc;
box-shadow: 3px 3px 5px 6px #ccc;
resize: none;
position:fixed;
display: block;
height:600px;
width:1000px;
max-width:1000px;
outline:none;
background-color:#3f3f3f;
color:whitesmoke;
font-family:Arial;
font-size:30px;
border-radius:10px;
text-align:left;
padding-right:20px;
padding-left:40px;
top: 50%;
left: 50%;
margin-left:-500px;
margin-top:-300px;
padding-top: 50px;
}
#Commentsection {
position:fixed;
top:50%;
margin-left:140px;
margin-top:-300px;
}
#nameAreaTitle {
font-family:Arial;
color:black;
font-weight:bold;
}
#nameArea {
font-family:Arial;
color:black;
width:300px;
height:40px;
font-size:30px;
}
#commentArea {
font-family:Arial;
color:black;
width:300px;
height:300px;
resize: none;
margin-top:10px;
font-size:20px;
}
#submitComment {
width:100px;
font-size:20px;
}
#postedComments{
position:absolute;
right:0px;
margin-top:10px;
margin-right:10px;
width:280px;
background-color:grey;
}
#postersName {
width:260px;
height:25px;
font-size:20px;
font-family:Arial;
background-color:white;
color:black;
border-color:black;
border-width:1px;
border-style:solid;
padding-left:10px;
font-weight:bold;
margin-top:10px;
}
#commentDate {
width:260px;
height:25px;
font-size:20px;
font-family:Arial;
background-color:white;
color:black;
border-color:black;
border-width:1px;
border-style:solid;
padding-left:10px;
}
#postersComment {
width:275px;
height:200px;
font-size:20px;
font-family:Arial;
background-color:white;
color:black;
border-color:black;
border-width:1px;
border-style:solid;
padding-left:10px;
resize:none;
}
li {
list-style-type:none;
}
Without looking at it too closely, you can probably add a container div or something that wraps all your code up, and then assign a min-width attribute to ensure that it never goes smaller than the given size.
Your layout seems to be relying on the width of your body and as your window size changes so will the width of your body. Having a wrapper with a min-width or declared width will make it so a horizontal scroll bar will appear when users have a window smaller than the width of your container.
And like others have stated, you have some nesting issues. General page layout will look like this:
<html>
<head>
<!-- Head Content -->
</head>
<body>
<!-- Page Content -->
<ul>
<li><!-- List Item --></li>
<li><!-- List Item --></li>
</ul>
</body>
</html>

Resources