Html 带有 id 和外部 css 样式表的表将不起作用或格式化

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16178427/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 07:48:59  来源:igfitidea点击:

table with id and external css stylesheet will not work or format

htmlcss

提问by joebanks

I have a table that I'm trying to format using my external style sheet. I wanted to add some padding to the whole table and maybe specific the text alignment. The page is:

我有一个表格,我正在尝试使用我的外部样式表对其进行格式化。我想在整个表格中添加一些填充,并且可能会指定文本对齐方式。页面是:

Its under the featured vehicles section.

它位于特色车辆部分。

Here is my css:

这是我的CSS:

table#featured{
text-align: center;
}

table#featured img{ 
border: none;
}

table#featured td{
border: solid #FFFFFF 3px;
}

Html:

网址:

<table id="featured">
    <tr>
        <td>
            <img src='/3/scripts/image_view.php/1_1.jpg?width=100&amp;image=/3/images/autos/1_1.jpg' alt='' />
            <br />127 Mazda RX7
            <br />12000.00
        </td>
    </tr>
</table>

After I upload it and I go look at the style.css file the css is not there. Its driving me crazy. Any help is greatly appreciated.

在我上传它并查看 style.css 文件后,css 不在那里。这让我疯狂。任何帮助是极大的赞赏。

Joe

回答by amit ghosh

You can write the css like this

你可以这样写css

#featured td{
text-align: center;
padding :5px;
}

#featured td{
border: solid #FFFFFF 3px;
}

#featured td img{
border: none;
}

and obviously link the external style sheet to the main html page.. :)

并且显然将外部样式表链接到主 html 页面.. :)

回答by Fellah

Check the link to the external css file.

检查外部 css 文件的链接。

<link rel="stylesheet" type="text/css" href="mystyle.css">

Make sure to add ../ to the mystyle.css, that will go up one folder.

确保将 ../ 添加到 mystyle.css,这将上升到一个文件夹。