Saturday, June 6, 2020

CSS left panel layout sample

HTML code:

<!--Force IE6 into quirks mode with this comment tag-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CSS Left Panel Layout</title>
<link rel="stylesheet" href="index.css"/>

<script type="text/javascript">
/*** Temporary text filler function. Remove when deploying template. ***/
var gibberish=["Ular melingkar di atas pagar.", "Satu Ribu, Dua Biru, Tiga Ribu, Empat Biru.", "Kelapa di Parut, Kepala di Garuk."]
function filltext(words){
for (var i=0; i<words; i++)
document.write(gibberish[Math.floor(Math.random()*3)]+" ")
}
</script>

</head>

<body>

<div id="leftpanel">
<div class="inner-content">

<h1>CSS Left Panel Layout</h1>
<h3>Sample text here</h3>

</div>
</div>


<div id="main-content">
<div class="inner-content">

<h2>Right Panel Title</h2>
<p><script type="text/javascript">filltext(125)</script></p>
<p style="text-align: center">Footer: <a href="#">CSS Left Panel Layout</a></p>

</div>
</div>


</body>
</html>

CSS code:

/* liquid layout with the left column being static, always in view. Tested and works in IE5+, Opera7+, and Firefox. */
body{
margin: 0;
padding: 0;
border: 0;
overflow: hidden;
height: 100%;
max-height: 100%;
}

#leftpanel{
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 200px; /*Width of left div*/
height: 100%;
overflow: hidden; /*Disable scrollbars. Set to "scroll" to enable*/
background: #f0f0f0;
color: black;
}

#main-content{
position: fixed;
top: 0;
left: 200px; /*Set left value to Width Of Left Div*/
right: 0;
bottom: 0;
overflow: auto;
background: #fff;
}

.inner-content{
margin: 15px; /*Margins for inner DIV inside each DIV (to provide padding)*/
}

* html body{ /*IE6 hack*/
padding: 0 0 0 200px; /*Set value to (0 0 0 WidthOfFrameDiv)*/
}

* html #maincontent{ /*IE6 hack*/
height: 100%;
width: 100%;
}

Reference:
http://www.dynamicdrive.com/
https://trinket.io/

No comments:

Post a Comment