Great Html Tab Panel Using CSS and Javascript
I needed a tab pane to put some content in my web pages. There are many solutions around
and I must say that they are quite good, but I had some extra requirements that I needed.
I did search around but I did not find what I wanted, so I ended up producing something and now I am sharing
it with you. The idea is not just to share the code but also explain
the issues involved.
The Tabbed Pane Content should be all downloaded with the page
This is quite a Web 2.0 thing, and I must say it was not an absolute requirement, but since I am at it
I may as well do it in a good way.
The requirement is that the content of the panels should be downloaded with the page that defines the panels
and therefore when the user switches panels there will not be any delay, the content is already there
.
The tab Panel should coexist with other content
Quite a few of the tabbed panels around basically take over the content. This simply means that
you design the page around the tabbed pane and it is quite difficult to put extra content in it.
I wanted a tab panel that fits inside some content I have
and not one that takes over my page.
Note that this means avoiding as much as possible fixed width and height
and using as much as possible
all the available screen size. Not easy...
The issues that have been solved
Before giving you the solution I will describe the issues involved, so you can understand better
what the code does and change it to suit your needs.
Where to store the different content
I could have stored the content in a Javascript variable and then push
it into
the current DIV (this may be something I do in the future) but as it is now I am inserting the
content of the different panels into different DIV, each one having a separate ID. This surely makes writing the
actual content of the panel easy.
How to overlap the various DIV
This is kind of simple, the way to overlap content is by means of using a DIV set to relative positioning
and then putt
相关文档:
visibility: hidden, visible
display: block, inline, none
visibility: 控制页面元素的显示和隐藏,不空值元素的位置特征。
document.getElementById("div").style.visibility = "hidden"; //隐藏元素
document.getElementById("div").style.visibility = "visible"; //显示元素
当元素在页面是隐藏时, ......
#dh
{
width:1003px;
height:36px;
background-image:url(images/mmain_03.gif)
}
#dh li
{
height:30px;
width:110px;
float:left;
list-style:none;
text-align:center;
margin:7px;
padding:5px;
}
#dh li a:link
{
font-size:16 ......
.equal {
margin-bottom:-32767px;
padding-bottom:32767px;
}
.left{
float:left;
margin-left:5px;
overflow:hidden;
width:295px;
}
.right {
float:right;
overflow:hidden;
width:245px;
}
<div class=’left equal’>数据任意长度,可以自行copy很长一断来测试</div>
......
这些都是之前学习的时候总结的,现在把它们都上传上来:
DIV+CSS面试八个题是之前在哪个网站看到了,现在怎么也找不到了,索性自己留一份吧!
一、超链接访问过后hover样式就不出现的问题?
被点击访问过的超链接样式不在具有hover和active了,解决方法是改变CSS属性的排列顺序: L-V-H-A
二、IE6的双倍边距BUG
......