Table of Contents
Reply to discussion (solution)
Home Web Front-end HTML Tutorial 关于table-row table-cell_html/css_WEB-ITnose

关于table-row table-cell_html/css_WEB-ITnose

Jun 24, 2016 am 11:39 AM

I recently helped a friend build a website. Since I have no practical experience, I can only learn while doing it. The page is very simple, HTML CSS, and finally uses CSS table layout in the body. Please see the code below.
The red part in the picture is two table-cells, placed inside a table-row. What confuses me is that the width of the cell cannot be adjusted. Using the border attribute has no effect at all. I don't know why. Please help me figure out where this problem lies.

I have never made a website before and I am in a hurry, so the code is a bit messy. Seniors, please work hard and help me figure out how to control the width of the columns. Thanks in advance!

<!doctype html><html><body>    <head>        <title> XX典藏官网-第四套人民币收藏网,第三套人民币收藏,第五套人民币,连体钞,纪念钞,人民币最新价格行情表及图片</title>        <meta http-equiv="X-UA-Compatible" content="IE=7" />         <meta name="baidu-site-verification" content="f8zIsHw8jjfPFf3L" />	    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />        <meta name="keywords" content="  人民币收藏,第四套人民币,第五套人民币,人民币价格,人民币收藏网,人民币收藏价格表,人民币收藏行情,第二套人民币,第四套人民币价格及图片,第三套人民币,第三套人民币价格及图片,第四套人民币大全套,第五套人民币价格表,纪念钞,奥运纪念钞最新价格,金银币价格,连体钞价格及图片">        <link rel="stylesheet" type="text/css" href="css/style_main.css" />	</head>   <body>          <div id="table_body">        <!--页眉-->            <div id="row_shuimo">                <div id="header_shuimo"><img src="./images/header_shuimo.png" width=""/></div>            </div>            <div id="row_nav">                <div id="header_logo">                    <a href="http://www.baidu.com/" alt="XX文化艺术公司"><img src="./images/src_logo.jpg" alt="XX典藏欢迎您"/></a>                </div>	                <div id="header_reg_login">                    <a href="http://www.baidu.com/" title="点击登录">登录   </a>                         <a href="http://www.baidu.com/" title="点击注册">新用户?注册</a>                </div>            </div>        <!--导航条和商品展示区-->            <!--行-->            <div id="row_show">                <div id="cell_list">                    <ul>                        <li id="li_nav_all"><strong>全部藏品分类</strong></li>                        <li id="li_nav_rmb">人民币收藏</li>                        <li id="li_nav_stamp">邮票收藏</li>                        <li id="li_nav_jinianbi">纪念币收藏</li>                        <li id="li_nav_lianti">连体收藏类</li>                        <li id="li_nav_jinyinbi">金银币类</li>                        <li id="li_nav_antique">古玩字画</li>                   </ul>                </div>                <!-- 行 -->                <div id="cell_goods">                    <div id="goods_table">                        <div id="goods_row1">                            <div id="cell_row1">                                <ul>                                    <li>                                        您的当前位置:首页                                      </li>                                    <li>                                        藏品展示区                                    </li>                                </ul>                            </div>                        </div>                           <div id="goods_row2">                            <p>goods </p>                        </div>                    </div>                </div>        </div>                <!--页脚-->        <div id="row_footer">            <div class="footer_div" id="footer_400">                <h3>咨询热线</h3>                <p>400-000-0000</p>            </div>            <div class="footer_div">                <ul class="footer_ul">                    <li>关于我们</li>                    <li><a href="footer/1.html">XX典藏简介</a></li>                    <li><a href="footer/1.html">企业文化</a></li>                    <li><a href="footer/1.html">招商与合作</a></li>                </ul>            </div>                            <div class="footer_div">                <ul class="footer_ul">                    <li>交易指南</li>                    <li><a href="footer/1.html">购物流程</a></li>                         <li><a href="footer/1.html">免责声明</a></li>                </ul>            </div>            <div class="footer_div">                    <ul class="footer_ul">                        <li>支付配送</li>                        <li><a href="footer/1.html">支付方式</a></li>                        <li><a href="footer/1.html">商品配送</a></li>                        <li><a href="footer/1.html">注意事项</a></li>                    </ul>            </div>        </div>    </div>  </body>  </html>
Copy after login


Here is style_main.css:
*{margin:0; padding:0;}/*页眉*/#header #header_nav ul li{	list-style-type:none;	float:right;	}#table_body{	display:table;	margin-left:auto;	margin-right:auto;}#table_body #row_shuimo{	display:table-row;	height:100px;	text-align:center;}#table_body #row_shuimo #header_shuimo{	display:table-cell;	}#table_body #row_nav{	display:table-row;		vertical-align:top;}#table_body #row_nav #header_logo{	display:table-cell;	width:300px;}#table_body #row_nav #header_reg_login{	display:table-cell;}/*展示部分*/#table_body #row_show{	display:table-row;	height:700px;}#table_body #row_show #cell_list{	display:table-cell;	border:solid,20px,#cc0;	border-radius:15px;	border-color:green;}#table_body #row_show #cell_goods{	display:table-cell;}#cell_list ul{	list-style-type:none;	width:130px;	/*color:purple;	*/	background-color:white;	border-style:solid;	border-top-left-radius:10px;	/*border-color:Red;*/	border-width:2px;	padding:0px;	/*float:left;*/}#table_body #row_show #cell_list ul li{	height:30px;	font-size:15px;	color:orange;	text-align:center;	border-style:solid;}#table_body #row_show #cell_list ul #li_nav_all{	color:Orange;	background-color:Green;	border-top-left-radius:8px;	border-top-right-radius:8px;}/*cell_goods*/#goods_table{	display:table;	height:inherit;}#goods_row1{	display:table-row;}#goods_row2{	display:table-row;}#cell_row1{	display:table-cell;	margin-left:0;}/*页脚部分*/ #row_footer{	display:table-row;} .footer_div{	display:table-cell;	width:20%;	height:100px;	float:left;} #row_footer #footer_400{	margin-left:150px;} .footer_ul{	list-style-type:none;	margin-left:10px;}
Copy after login


Reply to discussion (solution)

It’s easy to just adjust the width.

#cell_list ul{	width: 500px;}
Copy after login
Copy after login

As for the border, I use the Chrom browser and it is displayed.
A few suggestions: 1. Do not put divs in span tags. The tag is used to combine inline elements in the document, usually text;
2. Do not use the id attribute frequently on the page. On the one hand, it is not conducive to code reuse, on the other hand, it is prone to naming conflicts and script errors.

It is easy to just adjust the width,

#cell_list ul{	width: 500px;}
Copy after login
Copy after login

As for the border, I use the Chrom browser and it is displayed.
A few suggestions: 1. Do not put divs in span tags. The tag is used to combine inline elements in the document, usually text;
2. Do not use the id attribute frequently on the page. On the one hand, it is not conducive to code reuse, on the other hand, it is prone to naming conflicts and script errors.



Thank you for taking the time to read my code patiently.
The border problem has been solved. It was due to my own CSS syntax error that it could not be displayed. well! But the width problem is still not solved.
Please take a look at the picture below first. 1 and 2 are in one row, 3 and 4 are in one row, and 5 and 6 are in another row. The HTML code has not changed, but no matter how I set the width attributes of table, row and cell in CSS, it has no effect. Don't know why. Paste the image and CSS code below:

*{margin:0; padding:0;}/*页眉*/#table_body{	display:table;	margin-left:auto;	margin-right:auto;}#row_shuimo{	display:table-row;	height:100px;}#header_shuimo{	display:table-cell;		border:solid;	width:200px;}#header_test{display:table-cell;border:solid;}#table_body #row_nav{	display:table-row;		width:300px;}#table_body #row_nav #header_logo{	display:table-cell;	border:solid 5px red;	margin-right:300px;	}#table_body #row_nav #header_reg_login{	display:table-cell;}/*展示部分*/#table_body #row_show{	display:table-row;	height:700px;}#table_body #row_show #cell_list{	display:table-cell;	border-radius:15px;	border-color:green;	border:solid;}#table_body #row_show #cell_goods{	display:table-cell;	border:solid;}#cell_list ul{	list-style-type:none;	width:130px;	/*color:purple;	*/	background-color:white;	border-style:solid;	border-top-left-radius:10px;	/*border-color:Red;*/	border-width:2px;	padding:0px;	/*float:left;*/}#table_body #row_show #cell_list ul li{	height:30px;	font-size:15px;	color:orange;	text-align:center;	border-style:solid;}#table_body #row_show #cell_list ul #li_nav_all{	color:Orange;	background-color:Green;	border-top-left-radius:8px;	border-top-right-radius:8px;}/*cell_goods*/#goods_table{	display:table;	height:inherit;	border:solid;}#goods_row1{	display:table-row;}#goods_row2{	display:table-row;}#cell_row1{	display:table-cell;	margin-left:0;}/*页脚部分*/ #row_footer{	display:table-row;} .footer_div{	display:table-cell;	width:20%;	height:100px;	float:left;} #row_footer #footer_400{	margin-left:150px;} .footer_ul{	list-style-type:none;	margin-left:10px;}
Copy after login

Another table-cell is added to HTML, and the id in CSS is header_test

Browser Press F12 to view the elements. Check the id of the element you want to change, and then change the css. As for the problem that width does not take effect, I think it is because the right element is not selected

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

What is the purpose of the <progress> element? What is the purpose of the <progress> element? Mar 21, 2025 pm 12:34 PM

The article discusses the HTML &lt;progress&gt; element, its purpose, styling, and differences from the &lt;meter&gt; element. The main focus is on using &lt;progress&gt; for task completion and &lt;meter&gt; for stati

What is the viewport meta tag? Why is it important for responsive design? What is the viewport meta tag? Why is it important for responsive design? Mar 20, 2025 pm 05:56 PM

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

What is the purpose of the <datalist> element? What is the purpose of the <datalist> element? Mar 21, 2025 pm 12:33 PM

The article discusses the HTML &lt;datalist&gt; element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

What is the purpose of the <iframe> tag? What are the security considerations when using it? What is the purpose of the <iframe> tag? What are the security considerations when using it? Mar 20, 2025 pm 06:05 PM

The article discusses the &lt;iframe&gt; tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

What is the purpose of the <meter> element? What is the purpose of the <meter> element? Mar 21, 2025 pm 12:35 PM

The article discusses the HTML &lt;meter&gt; element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates &lt;meter&gt; from &lt;progress&gt; and ex

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

See all articles