How to make CSS 3 columns stay in their posisiton? - css

I have got a problem with my 3 columns layout (960.css).
This is the condition:
c-left,c-center,c-right
The query ORDER BY id_post DESC LIMIT 6 inside center column to show article as many as 6 articles works, but when i use LIMIT 12 it doesn't. columns-right will be in down side.
Any thoughts?
html:
<div class="grid_4">
<div class="populer_left">
<div class="title_kiri">
Berita Terpopuler
</div>
<div class="batas_tengah"></div>
<div class="b_populer">
<?php include 'beritapopuler.php';?>
</div>
</div>
</div>
<div class="grid_7">
<div class="populer_center">
<div class="title_tengah">
Berita Terbaru
</div>
<div class="batas_tengah"></div>
<div class="isi_berita">
<?php include 'loadar.php'; ?>
</div>
</div>
</div>
<div class="grid_5">
<div class="populer_right">
<div class="title_kanan">
Opini
</div>
<div class="batas_tengah"></div>
<div class="b_opini">
<?php include 'beritaopini.php'; ?>
</div>
</div>
</div>
Style:
.populer_left {
float:left;
width:220px;
height:auto;
clear:both;
padding-bottom:15px;
background:#29aa6b;
border-radius:2px;
}
.populer_right {
float:right;
width:280px;
height:auto;
clear:both;
padding-bottom:15px;
background:#3f83ab;
border-radius:2px;
}
.populer_center {
float:left;
display: inline-block;
vertical-align:top;
width:400px;
height:auto;
background:#0e62aa;
border-radius:2px;
}

You can use display table, and table-cell property.
Here: Fiddle http://jsfiddle.net/LUCNY/10/
#wrapper { border: 2px solid red;overflow:hidden; display: table; width:900px;}
.populer-left {
width: 220px;
display:table-cell;
float:left;
padding-bottom:15px;
background:#29aa6b;
border-radius:2px;
}
.populer-center {
display:table-cell;
width: 400px;
float:left;
background-color: green;
background:#0e62aa;
padding-bottom:15px;
border-radius:2px;
}
.populer-right {
display:table-cell;
width: 280px;
float:left;
padding-bottom:15px;
background:#3f83ab;
border-radius:2px;
}

Related

Full width block near floated one

I have two rows like this
<div class="container me">
<div class="message">
</div>
<div class="time">
</div>
</div>
<br />
<div class="container he">
<div class="message">
</div>
<div class="time">
</div>
</div>
with css like this
* {
padding:0;
margin:0;
}
.container {
width:500px;
height:50px;
outline:1px solid green;
}
.message {
width:250px;
height:50px;
border:1px solid red;
display:inline-block;
border-radius:5px;
position: relative;
}
.time {
width:50px;
height:50px;
background:orange;
}
.container.me .time {
float:right;
}
.container.he .time {
float:left;
}
and i am trying to make message block full possible width (100% minus time block), is it possible?
jsfiddle https://jsfiddle.net/Nerfair/t0t0q632/5/
You can set width for .message to width: calc(100% - 52px); - this 52px is a width of your .time div (50px) + 2px for borders of .message (left and right)
Edit: For IE8 support you cannot use that, so you can try the tricky thing like this: https://jsfiddle.net/L2pqhnsq/

2 floating divs on top of 2 centered divs

I'm trying to create something that will allow me to put something on top of images in this case, small images.
basically, it goes like this and both main divs are centered:
http://jsmith.elementfx.com/images/questions.png
tia.
Sorry, here is
HTML
<div id="container">
<div id="left"><img src="" width="130" height="130" style="border:2px solid #72d6fe" /></div>
<div id="leftimage"><h2>963</h2></div>
<div id="right"><img src="" width="130" height="130" style="border:2px solid #72d6fe" /></div>
<div id="rightimage"><h2>434</h2></div>
</div>
CSS
#container{
margin:0px auto;
width:320px;
text-align:center;
margin-bottom:20px;
}
#left {
float:left;
margin-left:15px;
margin-right:20px;
position:relative;
}
#leftimage{
position:absolute;
padding-top:2px;
margin-left:5px;
width:65px;
}
#right {
margin-right:15px;
}
#rightimage{
position:absolute;
padding-top:2px;
width:65px;
}
you have to use z-index and position to acheive it,
DEMO
HTML
<div id="container">
<div id="left"><img src="" width="130" height="130" style="border:2px solid #72d6fe" /></div>
<div id="leftimage"><h2>963</h2></div>
<div id="right"><div id="rightimage"><h2>434</h2></div><img src="" width="130" height="130" style="border:2px solid #72d6fe" /></div>
</div>
CSS
#container{
margin:0px auto;
width:320px;
text-align:center;
margin-bottom:20px;
}
#left {
float:left;
margin-left:15px;
margin-right:20px;
position:relative;
}
#leftimage{
position:absolute;
padding-top:2px;
margin-left:5px;
width:65px;
z-index:1;
}
#right {
position:relative;
margin-right:15px;
}
#rightimage{
margin-left:175px;
position:absolute;
z-index:1000;
}
use this code, the calculation of the width and height of images would be according to your images:
HTML
<div class="container">
<div class="img1">
<img src="https://cdn1.iconfinder.com/data/icons/windows-8-metro-style/128/test_tube.png" width="32" height="32" />
</div>
<div class="img2">
<img src="https://cdn1.iconfinder.com/data/icons/windows-8-metro-style/128/test_tube.png" width="32" height="32" />
</div>
</div>
CSS
.container{
width:270px;
margin:0 auto;
overflow:hidden;
}
.img1,.img2{
width:128px;
height:128px;
background:url(https://cdn1.iconfinder.com/data/icons/windows-8-metro-style/128/test_tube.png);
float:left;
margin-right:10px;
border:1px solid #000;
}
.img2{margin:0;}
DEMO jsfiddle for this
Demo Fiddle - Quad view with 3 layered images
<div class="container start">
<img src="http://www.placehold.it/300/555555"></img>
<div id="base1" class="base">
<img src="http://www.placehold.it/200/654321"></img>
<div id="overlay1" class="overlay">
<img src="http://www.placehold.it/100/123456"></img>
</div>
</div>
</div>
.base {
width: 200px;
height: 200px;
position: relative;
top: -290px;
left: 10px;
}
.overlay {
width:100px;
height:100px;
position: relative;
left: 10px;
top: -190px;
}
.container {
left:100px;
width: 300px;
height: 300px;
margin: 10px;
float: left;
}
.start {
clear: left;
}

CSS Issue with alignment of divs

I have an issue with the following CSS. The votes I wan't to be in the same height as the Title. Although it looks like the Votes is on the same div as tags and by div. So that the 3 items to the left looks shrunken. I am quite new to it so I fail to see what I have done wrong. I had it working before I changed the height from 54 to 60 pixels, but I assume that there is something else I have added as well.
#containerpostsmall {
width: 800px;
height:60px;
}
.votes {
height:60px;
width:100px;
float: left;
}
.number {
height:40px;
text-align: center;
}
.number-text {
height:20px;
text-align: center;
}
.texttags {
width:500px;
height:60px;
float: left;
}
.title {
height:40px;
width:500px;
font-size:32px;
overflow: hidden;
white-space: nowrap;
}
.tagsby {
height:20px;
width:500px;
float: left;
}
.tags {
float: left;
}
.by {
float: right;
}
I have the following code part:
<div id="containerpostsmall">
<div class="votes">
<div class="number">
<h1>6</h1>
</div>
<div class="number-text">
votes
</div>
</div>
<div class="votes">
<div class="number">
<h1>1</h1>
</div>
<div class="number-text">
answers
</div>
</div>
<div class="votes">
<div class="number">
<h1>4</h1>
</div>
<div class="number-text">
comments
</div>
</div>
<div class="texttags">
<div class="title">
We were very tired.
</div>
<div class="tagsby">
<div class="tags">
<span style="background-color: #ffffff; border-color: #000000;">Forest</span>
<span style="background-color: #ffffff; border-color: #000000;">Ocean</span>
</div>
<div class="by">
Peter |
2013-12-03 18:56:34
</div>
</div>
</div>
</div>
It looks to me like a default h1 formatting issue. Browsers are going to apply default styling to certain elements.
I set
h1{
margin: 0;
}
See fiddle: http://jsfiddle.net/kZLub/

Site name in header css?

I would put the site name in the middle of this header but unfortunately I can not do it, I've tried many combinations but I just can not. I'll post the source
CSS
.header {
background-color:#00B9ED;
height:50px;
border-bottom:0px;
padding-left:auto;
padding-right:auto;
width:100%;
}
#wrapper {
margin-left:auto;
margin-right:auto;
width:1000px;
padding-top:0px;
padding-bottom:0px;
}
.logo {
width:150px;
margin: 0 auto;
}
.logo img {
width:150px;
height:50px;
}
.logo:hover {
height:50px;
background-color:#A9E2F3;
cursor:pointer;
}
HTML
<div class="header">
<div id="wrapper">
<div class="logo">
<img src="image.png" />
</div>
</div>
</div>
have no idea how can I do? Thanks
Use Below Code
<style>
.header {
background-color:#00B9ED;
height:50px;
border-bottom:0px;
padding-left:auto;
padding-right:auto;
width:100%;
}
#wrapper {
margin-left:auto;
margim-right:auto;
padding-top:0px;
padding-bottom:0px;
}
.logo {
text-align: center;
}
.logo img {
width:150px;
height:50px;
}
.logo:hover {
height:50px;
background-color:#A9E2F3;
cursor:pointer;
}
</style>
<div class="header">
<div id="wrapper">
<div class="logo">
<a>Bhavin<img src="image.png"></a>
</div>
</div>
</div>
Always try to code with standards. You can use text-align but it is for align paragraph or other elements with text. Insted align I would recommend to use margin:0 auto;width:150px;.
Here you got jsFiddle
try this
CSS
#wrapper {
margin: 0 auto;
padding-bottom: 0;
padding-top: 0;
width: 1000px;
}
.logo {
margin: 0 auto;
width: 150px;
}
HTML
<div class="header">
<div id="wrapper">
<div class="logo">
logo<img src="image.png" alt="LOGO"/>
</div>
</div>
</div>

The HTML/CSS part for brackets [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am developing a cup system, and I would like to get some advice to the bracket-part. The desirable result should look something like this:
http://www.partyplanning101.com.php5-7.dfw1-1.websitetestlink.com/wp-content/uploads/2009/02/tornament_board.gif
I would like to build op the page using div's combined with CSS - and not tables. How should I make this most optimally? Do any of you have a sample of this?
I am only asking for help regarding the HTML/CSS part, nothing else.
This seemed interesting so I started developing, have to get back to work now so this is how far I got. The basics are laid out for you so you can finish it from here I think, though I will probably finish it in my spare time too and come and post it later
http://jsfiddle.net/AcuPp/
Update:
Finished - http://jsfiddle.net/AcuPp/3/
CSS
#container {
width: 800px;
height: 600px;
float: left;
}
section {
width: 130px;
height: 520px;
float: left;
}
section > div {
width: 100px;
height: 20px;
border: 1px solid #000;
margin: 10px 0;
background: #73789F;
color: white;
padding: 10px 10px 10px 20px;
}
section > div:nth-child(2n) {
margin-bottom: 40px;
}
.connecter {
width: 30px;
height: 520px;
float: left;
}
.line {
width: 30px;
height: 520px;
float: left;
}
.connecter div {
border: 1px solid #000;
border-left: none;
height: 50px;
width: 100%;
margin: 80px 0 0 1px;
}
.connecter div:first-child {
margin: 32px 0 0 1px;
}
.line div {
border-top: 1px solid #000;
margin: 133px 0 0 1px;
}
.line div:first-child {
margin-top: 55px;
}
#quarterFinals > div {
margin-top: 91px;
}
#quarterFinals > div:first-child {
margin-top: 37px;
}
#conn2 div {
margin-top: 133px;
height: 133px;
}
#conn2 div:first-child {
margin-top: 57px;
}
#line2 div {
margin-top: 270px;
}
#line2 div:first-child {
margin-top: 125px;
}
#semiFinals > div {
margin-top: 230px;
}
#semiFinals > div:first-child {
margin-top: 105px;
}
#conn3 div {
margin-top: 125px;
height: 270px;
}
#line3 div {
margin-top: 270px;
}
#final > div {
margin-top: 250px;
}
​
HTML
<article id="container">
<section>
<div>Player 1</div>
<div>Player 2</div>
<div>Player 3</div>
<div>Player 4</div>
<div>Player 5</div>
<div>Player 6</div>
<div>Player 7</div>
<div>Player 8</div>
</section>
<div class="connecter">
<div></div>
<div></div>
<div></div>
<div></div>
</div>
<div class="line">
<div>
</div><div>
</div><div>
</div><div>
</div>
</div>
<section id="quarterFinals">
<div></div>
<div></div>
<div></div>
<div></div>
</section>
<div class="connecter" id="conn2">
<div></div>
<div></div>
</div>
<div class="line" id="line2">
<div></div>
<div></div>
</div>
<section id="semiFinals">
<div></div>
<div></div>
</section>
<div class="connecter" id="conn3">
<div></div>
</div>
<div class="line" id="line3">
<div></div>
</div>
<section id="final">
<div></div>
</section>
</article>
​
My full, working solution is here: http://jsfiddle.net/t9feh/
I would prefer a solution with purely semantic markup that would be easy to read and amend with data that might trickle in later, like who wins each match.
So I started with a markup structure with players nested in matches, and matches nested in rounds.
HTML:
<div class="tournament">
<div class="round quarter-finals">
<div class="match" >
<div class="player">Player 1</div>
<div class="player winner">Player 2</div>
</div>
<div class="match">
<div class="player winner">Player 3</div>
<div class="player">Player 4</div>
</div>
<div class="match">
<div class="player">Player 5</div>
<div class="player winner">Player 6</div>
</div>
<div class="match">
<div class="player">Player 7</div>
<div class="player">Player 8</div>
</div>
</div>
<div class="round semi-finals">
<div class="match">
<div class="player">Player 2</div>
<div class="player winner">Player 3</div>
</div>
<div class="match">
<div class="player">Player 6</div>
<div class="player">Player 7</div>
</div>
</div>
<div class="round finals">
<div class="match">
<div class="player">Player 3</div>
<div class="player"></div>
</div>
</div>
<div class="round">
<div class="champion">
<div class="player"></div>
</div>
</div>
</div>
Note that a class for "winner" can be added to any player, and it will be styled appropriately.
The main challenge then is doing the connectors. Semantic markup means no design hooks. This then requires BG images. I used data-urls (see the utility I used at DataURL.net) to place these on "matches" elements.
CSS:
.tournament{width:720px;}
.round{
float:left;
}
.player{
font-family:arial;
width:120px;
height:20px;
padding:10px;
background:#73789F;
color:white;
}
.player.winner{background:green;}
.match{
padding:5px 50px 5px 0px;
}
/*QUARTER-FINALS*/
.quarter-finals .match{
height:100px;
background:right top no-repeat url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAABkAQMAAAD+JvEYAAAAA3NCSVQICAjb4U/gAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAAsSAAALEgHS3X78AAAAFnRFWHRDcmVhdGlvbiBUaW1lADEwLzEwLzEyGAKeIwAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNAay06AAAAAnSURBVCiRY/gPBgcYhjoNBPZQ/v4hQjeAHD0I3IGXRgpXqsbXEKEB2yGL0P7iVKIAAAAASUVORK5CYII=);
}
.quarter-finals .player{
}
.quarter-finals .player:first-child{
margin-bottom:5px;
}
/*SEMI-FINALS*/
.semi-finals .match{
padding-top:30px;
height:185px;
background:right top no-repeat url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAC5AQMAAABQhv7pAAAAA3NCSVQICAjb4U/gAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAAsSAAALEgHS3X78AAAAFnRFWHRDcmVhdGlvbiBUaW1lADEwLzEwLzEyGAKeIwAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNAay06AAAAArSURBVDiNY/gPBgcYRumBpYHAHsrfP0oPKboBFHmDwB2jNAk0Un77PwxoAJbztvAUr3KAAAAAAElFTkSuQmCC);
}
.semi-finals .player:first-child{
margin-bottom:70px;
}
/*FINALS*/
.finals .match{
padding-top:85px;
height:350px;
background:top right no-repeat url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAFeAQMAAAD9sN5nAAAAA3NCSVQICAjb4U/gAAAABlBMVEUAAAD///+l2Z/dAAAACXBIWXMAAAsSAAALEgHS3X78AAAAFnRFWHRDcmVhdGlvbiBUaW1lADEwLzEwLzEyGAKeIwAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNAay06AAAAA0SURBVEiJY/gPBgcYRulRepQmngYCeyh//yg9So/Sg45uAGXSQeCOUXqUHrI0Uj33fxjQAEJS8U50LMSKAAAAAElFTkSuQmCC);
}
.finals .player:first-child{
margin-bottom:180px;
}
/* CHAMP*/
.champion{padding-top:200px;}
You can do that. Alter the below code according to your div position.
CSS
h1 {
width:580px;
font-family:verdana,arial,helvetica,sans-serif;
font-size:18px;
text-align:center;
margin:40px auto;
}
#container {
width:580px;
font-family:verdana,arial,helvetica,sans-serif;
font-size:11px;
text-align:center;
margin:auto;
}
#container a {
display:block;
color:#000;
text-decoration:none;
background-color:#f6f6ff;
}
#container a:hover {
color:#900;
background-color:#f6f6ff;
}
#no1 {
width:190px;
line-height:60px;
border:1px solid #000;
margin:auto;
}
#no1 a {
height:60px;
}
#line1 {
font-size:0;
width:1px;
height:20px;
color:#fff;
background-color:#000;
margin:auto;
}
#line2 {
font-size:0;
width:424px;
height:1px;
color:#fff;
background-color:#000;
margin:auto;
}
#line3 {
font-size:0;
display:inline;
width:1px;
height:20px;
color:#fff;
background-color:#000;
margin-left:78px;
float:left;
}
#line4,#line5,#line6 {
font-size:0;
display:inline;
width:1px;
height:20px;
color:#fff;
background-color:#000;
margin-left:140px;
float:left;
}
#no2 {
display:inline;
border:1px solid #000;
clear:both;
margin-left:35px;
float:left;
}
#no2 a,#no4 a,#no8 a {
width:84px;
height:50px;
padding-top:8px;
}
#no3 {
display:inline;
border:1px solid #000;
margin-left:58px;
float:left;
}
#no3 a,#no5 a,#no6 a,#no7 a,#no9 a {
width:84px;
height:42px;
padding-top:16px;
}
#no4 {
display:inline;
border:1px solid #000;
margin-left:53px;
float:left;
}
#no5 {
display:inline;
border:1px solid #000;
margin-left:55px;
float:left;
}
#line7,#line13 {
font-size:0;
display:inline;
width:1px;
height:38px;
color:#fff;
background-color:#000;
margin-left:219px;
float:left;
}
#line8,#line14 {
font-size:0;
display:inline;
width:1px;
height:38px;
color:#fff;
background-color:#000;
margin-left:281px;
float:left;
}
#no6,#no8 {
display:inline;
border:1px solid #000;
margin-left:107px;
float:left;
}
#line9,#line11,#line15,#line17 {
font-size:0;
display:inline;
width:26px;
height:1px;
color:#fff;
background-color:#000;
margin-top:29px;
float:left;
}
#line10,#line12,#line16,#line18 {
font-size:0;
display:inline;
width:1px;
height:60px;
color:#fff;
background-color:#000;
float:left;
}
#line16,#line18 {
height:30px;
}
#no7,#no9 {
display:inline;
border:1px solid #000;
margin-left:169px;
float:left;
}
.clear {
clear:both;
}
HTML
<div id="container">
<div id="no1">Managing Director</div>
<div id="line1"></div>
<div id="line2"></div>
<div id="line3"></div>
<div id="line4"></div>
<div id="line5"></div>
<div id="line6"></div>
<div id="no2">Sales & Marketing Director</div>
<div id="no3">Production Director</div>
<div id="no4">Human Resources Director</div>
<div id="no5">Finance Director</div>
<div id="line7"></div>
<div id="line8"></div>
<div class="clear"></div>
<div id="no6">Factory Manager</div>
<div id="line9"></div>
<div id="line10"></div>
<div id="no7">Management Accountant</div>
<div id="line11"></div>
<div id="line12"></div>
<div class="clear"></div>
<div id="line13"></div>
<div id="line14"></div>
<div class="clear"></div>
<div id="no8">Quality Control Manager</div>
<div id="line15"></div>
<div id="line16"></div>
<div id="no9">Financial Accountant</div>
<div id="line17"></div>
<div id="line18"></div>
<div class="clear"></div>
</div>
</body>
</html>​
Demo here http://jsfiddle.net/ZRJRj/1/
You want to look at SVG ( http://www.w3schools.com/svg/default.asp ) or, alternatively, Canvas ( http://en.wikipedia.org/wiki/Canvas_element )
I would go with SVG. You'll need to calculate end points for your connector lines with some JavaScript, which you will draw with SVG right in the browser, and abstract it all neatly away behind simple interface. Actually, JavaScript is what will glue your entire application together, SVG is just for drawing, and HTML and CSS will aid you in presenting other parts of it.
Alternatively, you can use SVG to display the entire finals line-up. You will then use JavaScript to manipulate its contents to display proper team titles and relationships.
It will be beautiful.

Resources