How to write contents outside of table - css

I want to create a table in my wordpress website. i want to place the table in the right side. The problem is, if i want to write contents outsides like to left side of the table then how will i do it. Can you please give me an example?
I am beginner in css so plz forgive me for the writing style.
I want to make a style for a website like (the pic i have attached). Can you Please help me that how can I write freely in the left side of the table?

Use position: absolute:
#navbar {
position: absolute; left: 0;
width: 20%;
}
#content {
position: absolute; right: 0; /*Presuming this is the table*/
}

You should take a look at the display property of css, this is mainly used for aligning content on webpages.
http://www.w3schools.com/cssref/pr_class_display.asp
You mean a table inside the content div?
#content {
margin-left:20%;
}
#navbar {
float: left;
width: 20%;
}
.table-wrapper {
display:inline-block;
}
<div id="layout">
<div id="header">Top Header</div>
<div id="navbar">Navigation</div>
<div id="content">
<div class="table-wrapper">
<table><tr><td>table 1</td></tr></table>
</div>
<div class="table-wrapper">
<table><tr><td>table 2</td></tr></table>
</div>
</div>
<div id="footer">Bottom Footer</div>
</div>
http://jsfiddle.net/KhH42/1/

Something like this?
#wrapper {
border:solid 2px #000;
margin:20px;
}
#wrapper div[class*="col-"]{
float:left;
}
.col-1 { width:30%; background:#eee; }
.col-2 { width:30%; background:#e2e2e2; }
.col-3 { width:40%; background:#ccc; }
#wrapper:after { content:""; clear:both; display:block; }
<div id="wrapper">
<div class="col-1">
<p>col 1 content</p>
</div>
<div class="col-2">
<p>col 2 content</p>
</div>
<div class="col-3">
<table>
<tr>
<td>
my table
</td>
</tr>
</table>
</div>
</div>
http://jsfiddle.net/3LUqg/

Related

Hover on image not working properly

<div align="center">
<div class="se" style="width:60px;height:60px;"><img src="http://images.smh.com.au/2013/07/10/4558947/english_flag-60x60.jpg"/></div>
<div class="uk" style="width:60px;height:60px;"><img src="http://images.smh.com.au/2013/07/10/4558947/english_flag-60x60.jpg"/></div>
<div class="de" style="width:60px;height:60px;"><img src="http://images.smh.com.au/2013/07/10/4558947/english_flag-60x60.jpg"/></div></div>
<div> i dont want this menu div to jump up and down when hover</div>
css file:
.se {margin-top:-30px;}
.se:hover {margin-top:-15px;}
.uk {margin-top:-60px; margin-left:-150px;}
.uk:hover {margin-top:-45px;}
.de{margin-top:-60px; margin-left:150px;}
.de:hover {margin-top:-45px;}
I just want the flags to slide down when hover. As you see in my fiddle, it's acting strange depending on with flag i hover first.
This could probably be solved in an easier way? http://jsfiddle.net/XScjm/1/
I think you are in the wrong way to acomplish what you want, first you can't offset the image with margin because that affects all arround the element. And the way you are trying to position each <div> with margin is unrecommended.
Try to do it this way:
.center {
text-align:center;
}
.se, .uk, .de {
position:relative;
display:inline-block;
cursor:pointer;
}
.se:hover, .uk:hover, .de:hover {
top:15px;
}
Check this Demo
Have a look at this one :-
DEMO
<div align="center" class="one"></div>
.one{ height: 60px; }
try this:
.se, .uk, .de {
float: left;
margin-right: 5px;
margin-top: -40px;
}
.se:hover img, .uk:hover img, .de:hover img {
margin-top: 20px;
}
This will work. JSFiddle.
HTML
<div id="center" align="center">
<div class="flag" style="width:60px;height:60px;">
<img src="http://images.smh.com.au/2013/07/10/4558947/english_flag-60x60.jpg"/>
</div>
<div class="flag" style="width:60px;height:60px;">
<img src="http://images.smh.com.au/2013/07/10/4558947/english_flag-60x60.jpg"/>
</div>
<div class="flag" style="width:60px;height:60px;">
<img src="http://images.smh.com.au/2013/07/10/4558947/english_flag-60x60.jpg"/>
</div>
</div>
<div> i dont want this menu div to jump up and down when hover</div>
CSS
.flag {margin-top:-30px; position:relative; display:inline-block;}
.flag:hover { top:15px; }
#center { height: 50px; }

fit image inside div

I have a three div block inside main div which is head,content and footer.
I have facing few problems which are:
(1) images not fiting inside div
means i am try to find code for this situation:
<div style="height:10%">
<img src="abc.jpg" height="100%">
</div>
and
(2) I have a div which height is 80%,in this div i put three div their height is 20%, 60%, 20%.the div whose height is 60% has no data i write it for margin.(means first div 20% height has a data then 60% height for space then another div who has a data), so how to achive it?
(if possible please suggest without using margin-up or bottom
HTML code:
<div class="homebackground" style="height:100%; width:100%; background-image:url(../../stylesheets/images/Logo_with_Blu_bg.png); background-size:98% 88%">
<div class="bodyhead">
<img src="../../stylesheets/images/user_male.png"/>
</div>
<div style="height:80%">
<div style="width:100%">
<div class="mainbodyup" align="right">
<img src="../../stylesheets/images/phone.png"/>
</div>
<div class="mainbodyup"> </div>
<div class="mainbodyup">
<img src="../../stylesheets/images/groupchat.png"/>
</div>
</div>
<div style="height:60%; clear:both;" class="a">
<div class="mainbodymid"></div>
<div class="mainbodymid"></div>
<div class="mainbodymid"></div>
</div>
<div style="width:100%">
<div class="mainbodybot" align="right">
<img src="../../stylesheets/images/recent.png"/>
</div>
<div class="mainbodybot"> </div>
<div class="mainbodybot">
<img src="../../stylesheets/images/search.png"/>
</div>
</div>
</div>
<div style="height:10%;">
</div>
</div>
CSS:
.bodyhead
{
height:10%;
}
.bodyhead img
{
width: 10%;
}
.mainbodyup
{
height:20%;
width:33%;
float:left;
}
.mainbodyup img
{
width: 20%;
}
.mainbodymid
{
width:33%; float:left; padding:0px;
}
.mainbodybot
{
height:20%;
width:33%;
float:left;
}
.mainbodybot img
{
width: 20%;
}
.a:before
{
display: table;
content: " ";
}
.a:after
{
clear:both;
display: table;
content: " ";
}
If you want to fit the entire image in the div . try using
style="background:url('image-url') no-repeat; background-size: 100%;"
for the div which contains the Image . Rather using the image object .
style="background:url('image-url') no-repeat; background-size: contain;"
Use this code.
add one css to your existing stysheet
html, body{
height: 100%;
}

align 4 divs in parallel where one of the divs is empty

I'm a newbie with html so please be patient.
I'm trying to align 4 divs in parallel where the first,third and fourth div are static,the second div is empty and i need it to occupy the remain place e.g "width:auto".
I don't want to use table to solve the problem.
Is there a way to solve it using divs?
HTML:
<div class="container">
<div class="content" >
first
</div>
<div class="empty">
</div>
<div class="content">
third
</div>
<div class="content">
fourth
</div>
</div>
CSS:
.container{
strong textwidth:1020px;
height:40px;
}
.content{
position:relative;
background-color:#2cc2e7;
height:40px;
width:142px;
float:right;
margin-right:5px;
}
.empty{
background-color:#f1d486;
height:40px;
width:auto;
margin-right:5px;
}
You will need to change the order of the elements:
<div class="container">
<div class="first content">first</div>
<div class="content">third</div>
<div class="content">fourth</div>
<div class="empty"></div>
</div>
And then just float the first one to the left, other two to the right, and the .empty one, don't float it but set an overflow to auto β€”or hidden.
.content {
float: right;
width: 142px;
}
.first {
float: left;
}
.empty {
overflow: auto;
}
http://jsfiddle.net/GTbnz/
If you are prepared to add below the empty div then you could use the following:
<div class="empty">
</div>
with a style sheet of:
.container {
width:1020px;
height:40px;
display:table;
width:100%;
}
.container div {
height:40px;
display:table-cell;
}
.content {
background-color:#2cc2e7;
width:142px;
max-width:142px;
}
.empty {
background-color:#f1d486;
}
This was whichever of the 4 div's has a class 'empty' will auto-expand to fill the available space and the other div sizes will all be 142 px.

Middle div 100% width

How would i make my middle div take the remaining space left in width, but still staying in its place beside the 2 other divs?
Also if i remove either of the 2 divs on the sides, the main div should just take what space there is left?
Code:
<div class="row-fluid">
<div class="span12">
<div class="sidebar">1</div>
<div class="content-box">2</div>
<div class="sidebar">3</div>
</div>
</div>
http://jsfiddle.net/U3Hr5/2/
My suggestion is using a table since you want all of them to be on the same row but with their own heights.
Html:
<div class="row-fluid">
<table style="width: 100%">
<tr>
<td class="sidebar">1</td>
<td class="content-box">2</td>
<td class="sidebar">3</td>
</tr>
</table>
Css:
.sidebar {
width:225px;
background-color:blue;
}
.content-box {
background-color:red;
}
Here is the fiddle edit:
http://jsfiddle.net/mDpEX/
//Flipbed
If you don't want to use table for layout, you can make use of css3 display table, table-cell properties,
#container {
display: table;
width: 100%;
}
#left, #middle, #right {
display: table-cell;
height: 100px;
}
#left, #right {
width: 150px;
background: green;
}
#middle {
background: gray;
}
<div id="container">
<div id="left"></div>
<div id="middle"></div>
<div id="right"></div>
</div>
jsfiddle
More on css display properties
I assume you want something like this.
The HTML:
<div class="row-fluid">
<div class="span12">
<div class="sidebar">1</div>
<div class="content-box">2</div>
<div class="sidebar">3</div>
</div>
</div>
The CSS:
.sidebar {
float:left;
width:225px;
background-color:blue;
}
.content-box {
clear:left;
background-color:red;
width:225px;
}
Hope this helps.
Actually i didn't get your question correctly. If you are looking to align your div on to the remaining space after your first div ie after sidebar div simply put width of content-box as 50%(or the size you want).
It depends upon how much you want the layout to respond to resizing without using JavaScript and what browsers you're trying to cater for. If your layout is essentially static and you just want to respond to width changes then you can use something like this.
http://jsfiddle.net/U3Hr5/4/
HTML
<div class="row-fluid">
<div class="span12">
<div class="left sidebar">1</div>
<div class="content-box">2</div>
<div class="right sidebar">3</div>
</div>
</div>
CSS
.span12 {
position: relative;
}
.sidebar {
position: absolute;
top: 0;
width: 225px;
background-color:blue;
}
.left{left: 0;}
.right{right:0}
.content-box {
margin-left: 225px;
margin-right: 225px;
background-color:red;
}
You can try something like this http://jsfiddle.net/kKGVr/
Basically, if you don't wrap the content in a containing div it will expand to fill the available space - you can test this by removing the divs called #left or #right. This will also allow you to add a footer because no absolute positioning is used.
It will fall down, however, if the central column becomes longer than the side columns... solution? Not sure, perhaps use javascript to adjust the height of the side columns so they are always at least as long as the central column.
HTML:
<div id="wrapper">
<div id="right">...</div>
<div id="left">...</div>
content here
</div>
and CSS:
#left{width: 200px;background:#f00;float:left}
#right{width:200px;background:#0f0;float:right}

Improving My Basic CSS Formating for Math Equations

I'm working on an app for Windows 8 written in HTML, CSS, and JavaScript. I'm struggling with the CSS formatting part. I was able to get my app formated so it appears the way I want it to look somewhat but I would like to know how I can cleanup my CSS? I "Googled" and experimented until I got the layout I wanted but I would like to know the right, preferred way to format with CSS?
Below is my code:
<style type="text/css">
.quiz p {
margin-left: 120px;
}
.quizDiv2 {
margin-top: 220px;
width: 320px;
margin-left: auto;
margin-right: auto;
}
.cenDiv {
text-align: center ;
}
.cenDiv2 {
text-align: center ;
font-size:250%;
}
.alignleft {
float: left;
width:33.33333%;
text-align:left;
}
.aligncenter {
float: left;
width:33.33333%;
text-align:center;
}
.alignright {
float: left;
width:33.33333%;
text-align:right;
}​
.alignleft2 {
float: left;
}
.alignright2 {
float: right;
}
.container {
width:320px;
}
.first,
.second {
width:100%;
text-align:right;
display:table;
font-size:250%;
}
.plus {
width:auto;
float:left;
}
.number {
width:auto;
float:right;
}
.third {
width:100%;
text-align:right;
border-top:2px solid black;
border-color:black;
}
​ .correct {
font-size:250%;
}
</style>
</head>
<body>
<div class="quizDiv2">
<div id="textbox">
<p class="alignleft" id="statQuestionDiv">1/10</p>
<p class="aligncenter" id="statTimerDiv">02:27</p>
<p class="alignright" id="statScoreDiv">100%</p>
</div>
<div style="clear: both;"></div>
<div class="container">
<div class="first" id="mathProblemDiv1">1,483</div>
<div class="second">
<div class="plus">+</div>
<div class="number" id="mathProblemDiv2">4,573</div>
</div>
<div class="third">
<div class="result"></div>
</div>
</div>
<div class="cenDiv">
<!-- Fill in the blank div -->
<div id="fillBlankDiv">
<input id="userAnswer" type="text" />
<p>
<button id="btn7">7</button>
<button id="btn8">8</button>
<button id="btn9">9</button>
</p>
<p>
<button id="btn4">4</button>
<button id="btn5">5</button>
<button id="btn6">6</button>
</p>
<p>
<button id="btn1">1</button>
<button id="btn2">2</button>
<button id="btn3">3</button>
</p>
<p>
<button id="btn0">0</button>
<button id="btnNeg">+/-</button>
<button id="btnOk">OK</button>
</p>
</div>
</div>
<div class="cenDiv2">
<div id="checkDiv">CORRECT!</div>
</div>
</div>
</body>
</html>
You can use this easy CSS Cleaner. This site is amazing and will be great for cleaning up future css styles.
You can just copy and paste your styles in the CSS Input and select the size of the output. I recommend High.
http://www.cleancss.com/
Hope this helps!
Here is your code after cleaned up:
<style>
.quiz p{margin-left:120px;}
.quizDiv2{margin-top:220px;width:320px;margin-left:auto;margin-right:auto;}
.cenDiv{text-align:center;}
.cenDiv2{text-align:center;font-size:250%;}
.alignleft{float:left;width:33.33333%;text-align:left;}
.aligncenter{float:left;width:33.33333%;text-align:center;}
.alignright{float:left;width:33.33333%;text-align:right;}
.alignleft2{float:left;}
.alignright2{float:right;}
.container{width:320px;}
.first,.second{width:100%;text-align:right;display:table;font-size:250%;}
.plus{width:auto;float:left;}
.number{width:auto;float:right;}
.third{width:100%;text-align:right;border-top:2px solid #000;border-color:#000;}
.correct{font-size:250%;}
</style>
UPDATE: For best practices in css, If you have a style you are going to be using similar styles a good bit. For example text-aligning and font-sizes, and Columns. Make class in your css like this:
.onethird { width:33.33333%; }
.alignleft { text-align:left; }
.aligncenter { text-align:center; }
.alignright { text-align:right; }
.largefont { font-size:250%; font-family: arial,tahoma; font-weight:normal;}
Then on your html just add the classes, for example:
<div class="container">
<div class="first alignleft onethird">
</div>
<div class="second aligncenter onethird">
</div>
<div class="third alignright onethird">
</div>
</div>
That way use can apply the styles that you use over and over without having to add the to each css class. And then if you want to change a specific one, be more specific in calling your css and it will override the default styles. For example:
.container .onethird { width:100%; }
will override .onethird { width:33.33333%; }
This is how I work in css, and its helped me so much. Hope this helps!

Resources