10-07-15

テキストハイライト(選択)時の背景色を変える

demo

この箇所のテキスト部分を選択してみてください。通常このサイトではグレー背景に黒文字のハイライトとなりますが、赤色背景に白文字のハイライトになっているかと思います。

memo

作業内容

CSS3から定義された"selection"という擬似要素を使っています。なお、"selection"自体は突然CSS3のセレクタから削除されたそうですが、とりあえず下記の記述で適用はされます。

--- CSSはこんな感じ ---
::selection{ /* Safari and Opera */
 background:#ff0000;
 color:#000;
}
::-moz-selection{ /* Firefox */
 background:#ff0000;
 color:#fff;
}
ちなみにこんなのもありました。以下の英文をハイライトすると画像が浮かんできます。Text + Image + CSS3 = Crazy DeliciousでhtmlとCSSが自動生成されますが、凄いなぁ!元画像はこれです。
In the 1930s, the Asahi Baseball team was made of up Vancouver's best Japanese b
all players. Children as young as eight were recruited as potential players for
this prestigious team. Businesses would close their doors and the stands would b
e packed as the Japanese community cheered on their heroes. The Asahi first play
ed baseball within their own community but soon took on the larger, stronger Cau
casian teams. They developed their own brand of game to compensate for their sma
ll size and less powerful batting. With cat-like fielding, strategic bunting, li
ghtening quick base running and strategic play, the Asahi became an unstoppable
force. It was David against Goliath, and for five straight years, until the bomb
ing of Pearl Harbor, the Asahi won the Pacific Northwest Baseball Championship.
"It was a period when, you know, if you were Asian, especially on the West
Coast, people just thought you were almost subhuman. We didn't have the vote. Th
ere were places you couldn't go. I wondered for years why it was that all my mem
ories of theatres are looking down and it's because we had to go upstairs. So I
mean in that kind of world to be accepted as an equal, that meant a great deal."
Midge Ayukawa, Asahi baseball fan. "They were our team, regardless of wher
e you lived on the coast. They were fighting for us, fighting for all Japanese,
despite the hardships that were imposed on us. They showed us they could fight.
They showed us they could overcome anything." Kiyoshi Suga, Asahi secretary.
On December 7, 1941, Japan bombed targets across the Pacific, including Pearl
Harbor and Canadians defending Hong Kong. Japanese people became the enemy, and
, whether immigrants or Canadian born, they became enemy aliens. There was mass
evacuation of Japanese people to ghost towns, detention centres, and work camps.
Some families had only 24 hours to leave their homes, but amongst their treasur
ed possessions were Asahi photos, uniforms, scrapbooks and baseball gloves. The
Japanese community, including members of the Asahi team, was dispersed to a vari
ety of different sites. On January 23, 1943, Ottawa passed an Order in Cou
ncil under the War Measures Act that all confiscated property In the 1930s, the
Asahi Baseball team was made of up Vancouver's best Japanese ball players. Child
ren as young as eight were recruited as potential players for this prestigious t
eam. Businesses would close their doors and the stands would be packed as the Ja
panese community cheered on their heroes. The Asahi first played baseball within
their own community but soon took on the larger, stronger Caucasian teams. They
developed their own brand of game to compensate for their small size and less p
owerful batting. With cat-like fielding, strategic bunting, lightening quick bas
e running and strategic play, the Asahi became an unstoppable force. It was Davi
d against Goliath, and for five straight years, until the bombing of Pearl Harbo
r, the Asahi won the Pacific Northwest Baseball Championship. "It was a per
iod when, you know, if you were Asian, especially on the West Coast, people just
thought you were almost subhuman. We didn't have the vote. There were places yo
u couldn't go. I wondered for years why it was that all my memories of theatres
are looking down and it's because we had to go upstairs. So I mean in that kind
of world to be accepted as an equal, that meant a great deal." Midge Ayukawa, As
ahi baseball fan. "They were our team, regardless of where you lived on the
coast. They were fighting for us, fighting for all Japanese, despite the hardsh
ips that were imposed on us. They showed us they could fight. They showed us the
y could overcome anything." Kiyoshi Suga, Asahi secretary. On December 7,
1941, Japan bombed targets across the Pacific, including Pearl Harbor and Canadi
ans defending Hong Kong. Japanese people became the enemy, and, whether immigran
ts or Canadian born, they became enemy aliens. There was mass evacuation of Japa
nese people to ghost towns, detention centres, and work camps. Some families had
only 24 hours to leave their homes, but amongst their treasured possessions wer
e Asahi photos, uniforms, scrapbooks and baseball gloves. The Japanese community
, including members of the Asahi team, was dispersed to a variety of different s

参考記事

otani-webs.com / PozuPad / Copyright © 2010 LabPad All Rights Reserved.