如何设置HTML页面自适应宽度的table
今天装修百科网给各位分享table怎么设置网页宽的知识,其中也会对如何设置HTML页面自适应宽度的table进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在我们开始吧!
如何设置HTML页面自适应宽度的table
设置HTML页面自适应宽度的table的方法:
1、定义html页面table代码:

First Name
Last Name
Gender
Birth Date
Address
Zip Code
Nationality
Contact Number
Username
Course
Year
ID Number
Subjects
2、控制表格自适应的样式css代码:
***ntent {
width: 1100px;
height: 200px;
background: #fdfdfd;
margin: 0px auto;
position: relative;
top: 40px;
border: 1px solid #aaaaaa;
}
***ntent ***ntent-header {
width: 100%;
height: 40px;
background-color:#aaa;
background-image:-moz-linear-gradient(top,#eeeeee,#cccccc);
background-image:-webkit-gradient(linear,0 0,0 100%,from(#eeeeee),to(#cccccc));
background-image:-webkit-linear-gradient(top,#eeeeee,#cccccc);
background-image:-o-linear-gradient(top,#eeeeee,#cccccc);
background-image:linear-gradient(to bottom,#eeeeee,#cccccc);
border-bottom: 1px solid #aaaaaa;
}
***ntent-loader {
overflow: scroll;
}
***ntent-loader table {
width: auto;
background: #aaa;
}
***ntent-loader table tr {
background: #eee;
}
***ntent-loader tr td {
white-space: nowrap;
}
3、完整代码如下:
***ntent {
width: 800px;
height: 200px;
background: #fdfdfd;
margin: 0px auto;
position: relative;
top: 40px;
border: 1px solid #aaaaaa;
}
***ntent ***ntent-header {
width: 100%;
height: 40px;
background-color:#aaa;
background-image:-moz-linear-gradient(top,#eeeeee,#cccccc);
background-image:-webkit-gradient(linear,0 0,0 100%,from(#eeeeee),to(#cccccc));
background-image:-webkit-linear-gradient(top,#eeeeee,#cccccc);
background-image:-o-linear-gradient(top,#eeeeee,#cccccc);
background-image:linear-gradient(to bottom,#eeeeee,#cccccc);
border-bottom: 1px solid #aaaaaa;
}
***ntent-loader {
overflow: scroll;
}
***ntent-loader table {
width: auto;
background: #aaa;
}
***ntent-loader table tr {
background: #eee;
}
***ntent-loader tr td {
white-space: nowrap;
}
First Name
Last Name
Gender
Birth Date
Address
greennndddgreennndddgreennnddd
Mnddsdsdsweeweewrewrewrwerew
female
1999-09-08
jskfksdfsdflsdf;sldfsdkflsdfksdfkdsfldslf
4、运行效果如下:
表格的宽度随着内容的变化而变化。
如何设置HTML页面自适应宽度的table(表格)(一)
自适应宽度的table
table{
table-layout: fixed;
border-collapse: collapse;
width: 100%;
}
Header
Header
Header
Data
Data
Data
Data Data Data
HTML+CSS 怎样控制<table>标签里面<tr><td>的边长
一般来说有两用做法
1.使用div,li,a等元素定好位置之后,使用css中的active或者hover等方式改变元素的border的宽度和颜色,这种可以根据文字的大小改变大小。
2.使用本问题的table,可以实现定义好大小,然后再用上述的css方式处理边框。
如何设置HTML页面自适应宽度的table
table中添加样式 style="width:100%;",有用请采纳;//用样式比较规范;
如何设置HTML页面自适应宽度的table
12345如何设置HTML页面自适应宽度的table
如何设置HTML页面自适应宽度的table
设置HTML页面自适应宽度的table的方法:
1、定义html页面table代码:
First Name
Last Name
Gender
Birth Date
Address
Zip Code
Nationality
Contact Number
Username
Course
Year
ID Number
Subjects
2、控制表格自适应的样式css代码:
***ntent {
width: 1100px;
height: 200px;
background: #fdfdfd;
margin: 0px auto;
position: relative;
top: 40px;
border: 1px solid #aaaaaa;
}
***ntent ***ntent-header {
width: 100%;
height: 40px;
background-color:#aaa;
background-image:-moz-linear-gradient(top,#eeeeee,#cccccc);
background-image:-webkit-gradient(linear,0 0,0 100%,from(#eeeeee),to(#cccccc));
background-image:-webkit-linear-gradient(top,#eeeeee,#cccccc);
background-image:-o-linear-gradient(top,#eeeeee,#cccccc);
background-image:linear-gradient(to bottom,#eeeeee,#cccccc);
border-bottom: 1px solid #aaaaaa;
}
***ntent-loader {
overflow: scroll;
}
***ntent-loader table {
width: auto;
background: #aaa;
}
***ntent-loader table tr {
background: #eee;
}
***ntent-loader tr td {
white-space: nowrap;
}
3、完整代码如下:
***ntent {
width: 800px;
height: 200px;
background: #fdfdfd;
margin: 0px auto;
position: relative;
top: 40px;
border: 1px solid #aaaaaa;
}
***ntent ***ntent-header {
width: 100%;
height: 40px;
background-color:#aaa;
background-image:-moz-linear-gradient(top,#eeeeee,#cccccc);
background-image:-webkit-gradient(linear,0 0,0 100%,from(#eeeeee),to(#cccccc));
background-image:-webkit-linear-gradient(top,#eeeeee,#cccccc);
background-image:-o-linear-gradient(top,#eeeeee,#cccccc);
background-image:linear-gradient(to bottom,#eeeeee,#cccccc);
border-bottom: 1px solid #aaaaaa;
}
***ntent-loader {
overflow: scroll;
}
***ntent-loader table {
width: auto;
background: #aaa;
}
***ntent-loader table tr {
background: #eee;
}
***ntent-loader tr td {
white-space: nowrap;
}
First Name
Last Name
Gender
Birth Date
Address
greennndddgreennndddgreennnddd
Mnddsdsdsweeweewrewrewrwerew
female
1999-09-08
jskfksdfsdflsdf;sldfsdkflsdfksdfkdsfldslf
4、运行效果如下:
表格的宽度随着内容的变化而变化。
如何设置HTML页面自适应宽度的table
table中添加样式 style="width:100%;",有用请采纳;//用样式比较规范;
如何设置HTML页面自适应宽度的table
12345如何设置HTML页面自适应宽度的table
如何设置HTML页面自适应宽度的table
网友们上网通常会采用800×600、1024×768两种分辨率,由于网页不是用来给自己看的,所以我们必须让自己的网页能够兼顾这两种情况,让不同分辨率设置的网友都能够看到一个排版美观正确的网页。一、自然拉伸如果你的网站结构没有用到大量的图形来衔接,主要由表格来定结构,那么你就可以使用该方法。非常适用于主要由表格、文字来表达信息的简单的网页页面。制作表格时,只要你把表格的宽度属性定义为100%,表格就会根据分辨率的不同自行调整宽度。二、固定居中在800×600分辨率下制作的网页在1024×768分辨率的机器上打开,整个网页就会跑到左边;1024×768分辨率的网页在800×600分辨率的机器上有时也会变得"不堪入目"。两种分辨率各做一个吧?做起来费劲。所以目前普遍采用的方法是固定居中法!现在大多数网民都还在用800*600的分辨率,所以我们一般可以以此分辨率为主。只要在网页原代码的后紧加一句,前加一句就OK了。不过有几个问题这是要注意一下,第一个要注意的是上面说到的百分比的问题,表格、单元格的宽度单位最好要使用像素单位,而不要用百分比。例如width=770。如果你的表格宽度设的是百分比,那么使用大于800×600的像素时,网页就会拉宽,这样网页可能会变形。在中加入leftmargin=0,即这种情况下,800×600支持的表格宽度为780像素时不会出现滚动条。还有一点要注意的是不能用DW中的层来定位。三、兵分两路如果你的网页不经常更新,而且对页面效果极其在意,那好,你就设计两个页面,分别对应800×600和1024×768两种分辨率。然后根据不同的分辨率进行跳转就行了。例如:
在html中怎样控制表格的宽度
表格的宽度设置都知道: ..
宽度虽然是这样设置的,但是的内容如果超出就还是可能会改变table的宽度,
这样就有两种情况,如果你不想改变宽且也不想改变行高,可是设置: overflow: hidden;text-overflow:ellipsis;
而如果你的高度可以改变,及单元格的内容超出可以自动换行的话,可以设置 <table style="
word-break: break-all; word-wrap:break-word;" ...>...