我正在尝试更改我正在处理的页面上某个特定文本行的文本对齐方式,但实际上并没有太成功。我已经尝试过使用div class和div id以及p class和p id并在CSS文件中进行修改,但它似乎并不适用于我。我试图将“专注于记忆......”的中心放在中心位置。这是我的HTML和CSS文件:
body {
background-color: #008000;
}
h1 {
border-style: double;
font-family: times-new-roman;
color: white;
}
p {
color: white;
font-family: times-new-roman;
}
h2 {
color: #ffffff;
}
a:link {
color: blue;
}
a:visited {
color: purple;
}
<link rel="stylesheet" href="style.css">
<p style="text-align:center;">Dedicated to the memory of Rhodesia's special forces operators</p>
<br>
<br>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/7/77/Melander_and_Hupli_RLI_1979_simulation_4_%28cropped%29.jpg" width=300 height=200></p>
<span style=f ont-family="times-new-roman" font-weight="200"><h2>Rhodesian Light Infantry</h2></span>
<p class="regular">The Rhodesian Light Infantry was formed on February 1st, 1961. It was part of the army of the Central African Federation. This unit was Rhodesia's equivalent to the United States' 75th Ranger Regiment When the war against black nationalist guerrillas
broke out in the 1960s, they played a crucial role in counterterrorism operations. In the latter stages of the conflict, the unit became trained in airborne operations. Throughout the RLI's history, it was an exclusively white unit. Volunteers from
all throughout the world fought and died in the Rhodesian Light Infantry. In October 1980, the RLI was officially disbanded following the formation of Zimbabwe.</p>
<br>
<br>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/b/b6/Selous_Scouts_II.jpg" width=200 height=200></p>
<h2>Selous Scouts</h2>
<p class="regular2">The Selous Scouts were created in 1973 during the Rhodesian Bush War. Their name came from famed hunter Frederick Courtney Selous. Ronald Reid-Daly commanded this notable unit. The Shona phrase <i>Pamwe chete</i> or <q>all together</q> was the Selous
Scouts' motto. The Selous Scouts have 68% of all enemy deaths during the Rhodesian Bush War to their credit. Like other famed Rhodesian units, the Selous Scouts were disbanded upon the forming of the new government of Zimbabwe.</p>
<br>
<br>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/2/2e/C_Squadron_%28Rhodesian%29_SAS%2C_1953.jpg" width=400 height=200></p>
<h2>Rhodesian Special Air Service</h2>
<p class="regular3">The history of the Rhodesian Special Air Service goes back to the Malayan Emergency. <q>C</q> Squadron of the SAS was made up of volunteers from Southern Rhodesia. Once this unit had completed their tour of duty in Malaya, they were disbanded. The Rhodesian
Special Air Service was reactivated in the 1960s and fought during the insurgency against African nationalist forces. Upon Robert Mugabe's ascension to the Zimbabwean presidency in 1980, the Rhodesian SAS was disbanded permanently.</p>
答案 0 :(得分:0)
确实有效,请参阅代码段。
<h1>Special Forces of Rhodesia</h1>
<p style="text-align:center;">Dedicated to the memory of Rhodesia's special forces operators</p>
<br>
<br>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/7/77/Melander_and_Hupli_RLI_1979_simulation_4_%28cropped%29.jpg"
width=300 height=200></p>
<span style= font-family="times-new-roman" font-weight="200"><h2>Rhodesian Light Infantry</h2></span>
<p class="regular">The Rhodesian Light Infantry was formed on February 1st, 1961. It was part of the army of the Central African
Federation. This unit was Rhodesia's equivalent to the United States' 75th Ranger Regiment When the war against black
nationalist guerrillas broke out in the 1960s, they played a crucial role in counterterrorism operations.
In the latter stages of the conflict, the unit became trained in airborne operations. Throughout the RLI's history, it
was an exclusively white unit. Volunteers from all throughout the world fought and died in the Rhodesian Light Infantry.
In October 1980, the RLI was officially disbanded following the formation of Zimbabwe.</p>
<br>
<br>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/b/b6/Selous_Scouts_II.jpg" width=200 height=200></p>
<h2>Selous Scouts</h2>
<p class="regular2">The Selous Scouts were created in 1973 during the Rhodesian Bush War. Their name came from famed hunter
Frederick Courtney Selous. Ronald Reid-Daly commanded this notable unit. The Shona phrase <i>Pamwe chete</i> or <q>all together</q>
was the Selous Scouts' motto. The Selous Scouts have 68% of all enemy deaths during the Rhodesian Bush War to their credit.
Like other famed Rhodesian units, the Selous Scouts were disbanded upon the forming of the new government of Zimbabwe.</p>
<br>
<br>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/2/2e/C_Squadron_%28Rhodesian%29_SAS%2C_1953.jpg" width=400
height=200></p>
<h2>Rhodesian Special Air Service</h2>
<p class="regular3">The history of the Rhodesian Special Air Service goes back to the Malayan Emergency. <q>C</q> Squadron of the SAS was
made up of volunteers from Southern Rhodesia. Once this unit had completed their tour of duty in Malaya, they were disbanded.
The Rhodesian Special Air Service was reactivated in the 1960s and fought during the insurgency against African nationalist
forces. Upon Robert Mugabe's ascension to the Zimbabwean presidency in 1980, the Rhodesian SAS was disbanded permanently.</p>
&#13;
答案 1 :(得分:0)
它适用于CSS中的ID,但它应该已经运行。有一个开放式标签,关闭或删除它。您的内联CSS无效。
<span style= font-family="times-new-roman" font-weight="200">
<span style="font-family: times-new-roman" font-weight="200">
<!DOCTYPE html>
<html>
<head>
<style>
body
{
background-color:#008000;
}
h1{
border-style:double;
font-family:times-new-roman;
color:white;
}
p{
color: white;
font-family:times-new-roman;
}
h2{
color:#ffffff;
}
a:link{
color:blue;
}
a:visited{
color:purple;
}
#centerTitle{
text-align: center;
}
</style>
<title>My first web page</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Special Forces of Rhodesia</h1>
<p id="centerTitle">Dedicated to the memory of Rhodesia's special forces operators</p>
<br>
<br>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/7/77/Melander_and_Hupli_RLI_1979_simulation_4_%28cropped%29.jpg"
width=300 height=200></p>
<span style="font-family: times-new-roman" font-weight="200"><h2>Rhodesian Light Infantry</h2></span>
<p class="regular">The Rhodesian Light Infantry was formed on February 1st, 1961. It was part of the army of the Central African
Federation. This unit was Rhodesia's equivalent to the United States' 75th Ranger Regiment When the war against black
nationalist guerrillas broke out in the 1960s, they played a crucial role in counterterrorism operations.
In the latter stages of the conflict, the unit became trained in airborne operations. Throughout the RLI's history, it
was an exclusively white unit. Volunteers from all throughout the world fought and died in the Rhodesian Light Infantry.
In October 1980, the RLI was officially disbanded following the formation of Zimbabwe.</p>
<br>
<br>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/b/b6/Selous_Scouts_II.jpg" width=200 height=200></p>
<h2>Selous Scouts</h2>
<p class="regular2">The Selous Scouts were created in 1973 during the Rhodesian Bush War. Their name came from famed hunter
Frederick Courtney Selous. Ronald Reid-Daly commanded this notable unit. The Shona phrase <i>Pamwe chete</i> or <q>all together</q>
was the Selous Scouts' motto. The Selous Scouts have 68% of all enemy deaths during the Rhodesian Bush War to their credit.
Like other famed Rhodesian units, the Selous Scouts were disbanded upon the forming of the new government of Zimbabwe.</p>
<br>
<br>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/2/2e/C_Squadron_%28Rhodesian%29_SAS%2C_1953.jpg" width=400
height=200></p>
<h2>Rhodesian Special Air Service</h2>
<p class="regular3">The history of the Rhodesian Special Air Service goes back to the Malayan Emergency. <q>C</q> Squadron of the SAS was
made up of volunteers from Southern Rhodesia. Once this unit had completed their tour of duty in Malaya, they were disbanded.
The Rhodesian Special Air Service was reactivated in the 1960s and fought during the insurgency against African nationalist
forces. Upon Robert Mugabe's ascension to the Zimbabwean presidency in 1980, the Rhodesian SAS was disbanded permanently.</p>
</body></html>
&#13;
答案 2 :(得分:0)
语法无效。头部有一个开放式标签。 删除样式标记或关闭它。
在p。
之后还有一个内联样式问题<span style= font-family="times-new-roman" font-weight="200">
应该是
<span style="font-family: times-new-roman" font-weight="200">
适用于Chrome和Edge