我无法通过CSS

时间:2017-07-12 12:56:43

标签: html css heading

我刚开始使用HTML和CSS。我从html.net学习了教程,现在有了CSS的问题。

我希望我的标题(h1)的字体颜色为白色。如果我在HTML文件中编写CSS代码,但如果我将完全相同的代码写入外部CSS文件,它就无法工作。我很确定我正确引用了CSS文件,因为我可以通过相同的CSS文件设置标签和主体的样式。

的style.css:

<style>
h1 
{
    color: #FFFFFF !important;
}
label
{
    color:#FFFFFF;
    font-family:consolas;
    font-size:120%;
}
body
{
    background-color:#AA5555;
}
</style>

的support.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="de">
<head>
    <title>Support</title>
    <link rel="stylesheet" type="text/css" href="style/style.css" />
</head>
<body>
    <div>
        <h1>Heading</h1>
        <label>Test</label>
    </div>
</body>
</html>

身体的背景颜色有效。标签的样式有效。但不是标题h1的前景。我只有这个CSS文件,我已经在几个浏览器(Chrome,Firefox,IE,Opera)上尝试过,每个浏览器都有同样的问题。我也尝试使用h2 / h3,但没有机会将这个标题设置为风格。

我甚至尝试过没有DTD和xmlns。我需要了解正在发生的事情并解决我的问题。我是否需要特定版本或CSS / HTML的东西?我之前从未使用过这些东西,也不知道如何排除故障或修复它。

谢谢:)

3 个答案:

答案 0 :(得分:2)

删除外部文件中的<style>标记。不需要。

答案 1 :(得分:2)

您不需要在css文件的开头添加- name: update cache apt: update_cache: yes async: 1 poll: 0 - name: update cache apt: update_cache: yes async: 1 poll: 0 标记。这是html,而不是CSS语法。

答案 2 :(得分:1)

  

的style.css:

$servers = (Get-Clipboard).trim() #server1..100
$KB = (Get-Clipboard).trim() -split ', ' #KB4022714, KB4022717, KB4022718, KB4022722, KB4022727, KB4022883, KB4022884, KB4022887, KB4024402, KB4025339, KB4025342, KB4021903, KB4021923, KB4022008, KB4022010, KB4022013, KB3217845

$servers | Split-Pipeline -Verbose -Variable KB -Count 10 { process {
        $hash = [ordered]@{}
        try
        {
            $hash.Hostname = $_
            $os = gwmi win32_operatingsystem -ComputerName $_ -ErrorAction Stop
            $hash.OS = $os.Caption
            $hash.Architecture = $os.OSArchitecture
            $today = [Management.ManagementDateTimeConverter]::ToDateTime($os.LocalDateTime)
            $hash.LastReboot = [Management.ManagementDateTimeConverter]::ToDateTime($os.LastBootUpTime)
            $hash.DaysSinceReboot = ($today - $hash.LastReboot).Days
        }
        catch
        {
            $hash.OS = $Error[0]
            $hash.Architecture = 'N/A'
            $hash.LastReboot = 'N/A'
            $hash.DaysSinceReboot = 'N/A'
        }

        try
        {
            $hash.PendingReboot = icm -cn $_ {
                if (Get-ChildItem "HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending" -EA SilentlyContinue) { return $true }
                if (Get-Item "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired" -EA SilentlyContinue) { return $true }
                if (Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager" -Name PendingFileRenameOperations -Ea SilentlyContinue) { return $true }
                try
                {
                    $util = [wmiclass]"\\.\root\ccm\clientsdk:CCM_ClientUtilities"
                    $status = $util.DetermineIfRebootPending()
                    if(($status -ne $null) -and $status.RebootPending)
                    {
                        return $true
                    }
                }
                catch{}
                return $false
            }
        }
        catch
        {
            $hash.PendingReboot = 'N/A'
        }

        try
        {
            $hotfix = Get-HotFix -ComputerName $_ -Id $KB -ErrorAction Stop
            if ($hotfix)
            {
                $hash.Hotfix = $hotfix.HotFixID -join ','
            }
            else
            {
                $hash.Hotfix = "No Hotfix from the list applied"
            }        
        }
        catch
        {
            $hash.Hotfix = $Error[0]
        }
        $obj = New-Object -TypeName PSObject -Property $hash
        $obj | Export-Csv c:\temp\hotfixes.csv -NoTypeInformation -Append -Force
    }
}

这是你的错误...... HTML标签不属于任何外部样式表; CSS规则。