天天看點

css :before :after

p:before是在p标簽裡面的前部分,after是在p标簽裡面的後部分

<!doctype html>

<html>

<head>

<style>

p:before

{

content:"前面:";

background-color: #ff0000;

}

p:after

content:"後面:";

background-color: #0000ff;

p {

background-color: #00ffff;

</style>

</head>

<body>

<p>我是唐老鴨。</p>

<p>我住在 duckburg。</p>

<p><b>注釋:</b>對于在 ie8 中工作的 :before,必須聲明 doctype。</p>

</body>

</html>