SCSS嵌套问题

时间:2017-01-01 21:33:24

标签: html css sass

我试图在div中设置H3和p标签的样式。

我有这段代码(没有为p标签设置样式) -

( ! ) Notice: Undefined index: username in C:\wamp64\www\Restourant\include\addrestourant.php on line 3
Call Stack
#   Time    Memory  Function    Location
1   0.0006  276912  {main}( )   ...\addrestourant.php:0

( ! ) Notice: Undefined index: address in C:\wamp64\www\Restourant\include\addrestourant.php on line 4
Call Stack
#   Time    Memory  Function    Location
1   0.0006  276912  {main}( )   ...\addrestourant.php:0

( ! ) Notice: Undefined index: restype in C:\wamp64\www\Restourant\include\addrestourant.php on line 5
Call Stack
#   Time    Memory  Function    Location
1   0.0006  276912  {main}( )   ...\addrestourant.php:0

( ! ) Notice: Undefined index: zipcode in C:\wamp64\www\Restourant\include\addrestourant.php on line 6
Call Stack
#   Time    Memory  Function    Location
1   0.0006  276912  {main}( )   ...\addrestourant.php:0

( ! ) Notice: Undefined index: mobile in C:\wamp64\www\Restourant\include\addrestourant.php on line 7
Call Stack
#   Time    Memory  Function    Location
1   0.0006  276912  {main}( )   ...\addrestourant.php:0

( ! ) Notice: Undefined index: email in C:\wamp64\www\Restourant\include\addrestourant.php on line 8
Call Stack
#   Time    Memory  Function    Location
1   0.0006  276912  {main}( )   ...\addrestourant.php:0

( ! ) Notice: Undefined index: latitude in C:\wamp64\www\Restourant\include\addrestourant.php on line 9
Call Stack
#   Time    Memory  Function    Location
1   0.0006  276912  {main}( )   ...\addrestourant.php:0

( ! ) Notice: Undefined index: longitude in C:\wamp64\www\Restourant\include\addrestourant.php on line 10
Call Stack
#   Time    Memory  Function    Location
1   0.0006  276912  {main}( )   ...\addrestourant.php:0

( ! ) Notice: Undefined index: time in C:\wamp64\www\Restourant\include\addrestourant.php on line 11
Call Stack
#   Time    Memory  Function    Location
1   0.0006  276912  {main}( )   ...\addrestourant.php:0

( ! ) Notice: Undefined index: time2 in C:\wamp64\www\Restourant\include\addrestourant.php on line 12
Call Stack
#   Time    Memory  Function    Location
1   0.0006  276912  {main}( )   ...\addrestourant.php:0

( ! ) Notice: Undefined index: status in C:\wamp64\www\Restourant\include\addrestourant.php on line 14
Call Stack
#   Time    Memory  Function    Location
1   0.0006  276912  {main}( )   ...\addrestourant.php:0

( ! ) Notice: Undefined index: browsers in C:\wamp64\www\Restourant\include\addrestourant.php on line 15
Call Stack
#   Time    Memory  Function    Location
1   0.0006  276912  {main}( )   ...\addrestourant.php:0

( ! ) Notice: Undefined variable: imagepath in C:\wamp64\www\Restourant\include\addrestourant.php on line 70
Call Stack
#   Time    Memory  Function    Location
1   0.0006  276912  {main}( )   ...\addrestourant.php:0

这个块(用于标识p标签) -

.marketing-single-page-titles{
h3 {
  margin: 0;
  padding: 0;
p {
  margin: 0;
  padding: 0;
  position: relative;
  top: -5px;
  color: $marketing-blue;
  font-weight: bold;
}}}

是否有理由在第一个块中忽略p标签的样式?

2 个答案:

答案 0 :(得分:3)

正确格式化代码会显示p应嵌套在h3

以下显示您的代码格式正确,突出显示您的问题:

.marketing-single-page-titles {
  h3 {
    margin: 0;
    padding: 0;

    p {
      margin: 0;
      padding: 0;
      position: relative;
      top: -5px;
      color: $marketing-blue;
      font-weight: bold;
    }
  }
}

它应该如何(注意闭合花括号的位置):

.marketing-single-page-titles {
  h3 {
    margin: 0;
    padding: 0;
  }

  p {
    margin: 0;
    padding: 0;
    position: relative;
    top: -5px;
    color: $marketing-blue;
    font-weight: bold;
  }
}

答案 1 :(得分:1)

只有当p在h3标签内时,第一个块才有效;类似的东西:

<h3>My nice title with a <p> paragrahp inside</p></h3>

段落问题的初始规则转换为

.marketing-single-page-titles h3 p {.....

这就是原因。

相关问题