div 类和样式在 PHP 中一起使用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10535827/
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-24 22:24:54  来源:igfitidea点击:

div class and style together in PHP

phpcss-tables

提问by user1384668

I try to make div class and style together, but somehow style is not working. I don't find answer.. Here is the code:

我尝试将 div 类和样式放在一起,但不知何故样式不起作用。我没有找到答案..这是代码:

PHP

PHP

<div class="table">
<p><b>TEXT here</b><br />
...</p>
<div class="table_cell" style="width=180px !important; color=red !important;"><p>1<br />2<br />3<br />4<br />5<br />6</p></div>
<div class="table_cell" style="width=645px !important;"><p><b>&euro; 282</b><br /></p></div>
<p>Good luck in the future</p></div>

CSS

CSS

    div.table{
margin: 10px;
padding: 10px;
width: 825px;
border: 1px solid;
background: #E0F8EC;
border-radius:10px;
}

div.table_cell{
margin-top: 10px;
margin-bottom: 10px;
float: left;
}

Style defined in div is not working, except one from external css file.

div 中定义的样式不起作用,除了来自外部 css 文件的样式。

回答by Denys Séguret

Follow css syntax in your style attribute :

在您的样式属性中遵循 css 语法:

style="width:180px; color:red;"

回答by Dave

In your style, use the same name:value;syntax that you use in your CSS (notice the colon (:) between the two:

在您的样式中,使用name:value;您在 CSS 中使用的相同语法(注意两者之间的冒号 (:):

<div class="table">
<p><b>TEXT here</b><br />
...</p>
<div class="table_cell" style="width:180px !important; color:red !important;"><p>1<br />2<br />3<br />4<br />5<br />6</p></div>
<div class="table_cell" style="width:645px !important;"><p><b>&euro; 282</b><br /></p></div>
<p>Good luck in the future</p></div>

回答by K..

the syntax is like width: 100px !importantand not width=100px !important

语法是一样的,width: 100px !important而不是width=100px !important