::first-line
Baseline
åºãå©ç¨å¯è½
*
ãã®æ©è½ã¯åºãå®è£ ããã¦ãããå¤ãã®ãã¼ã¸ã§ã³ã®ç«¯æ«ããã©ã¦ã¶ã¼ã§åä½ãã¾ãã2015å¹´7æä»¥éããã¹ã¦ã®ãã©ã¦ã¶ã¼ã§å©ç¨å¯è½ã§ãã
* ãã®æ©è½ã®ä¸é¨ã¯ã対å¿ã¬ãã«ãç°ãªãå ´åãããã¾ãã
::first-line 㯠CSS ã®æ¬ä¼¼è¦ç´ ã§ããããã¯ã³ã³ããã¼ã®å
é è¡ã«ã¹ã¿ã¤ã«ãé©ç¨ãã¾ãã
試ãã¦ã¿ã¾ããã
p::first-line {
font-size: 1.2rem;
font-weight: bold;
text-decoration: underline;
}
<p>
In warm ocean waters around the world, you may see a strange sight: A fish
leaping from the water and soaring dozens of meters before returning to the
ocean's depths. Early Mediterranean sailors thought these flying fish returned
to the shore at night to sleep, and therefore called this family of marine
fish Exocoetidae.
</p>
::first-line ã®å¹æã¯ãè¦ç´ å
ã®ããã¹ãã®å
é è¡ã®é·ãã¨ã³ã³ãã³ãã«ãã£ã¦å¶éããã¾ããå
é è¡ã®é·ãã¯ãè¦ç´ ã®å¹
ãææ¸ã®å¹
ãããã¹ãã®ãã©ã³ããµã¤ãºãªã©ãå¤ãã®è¦å ã«ä¾åãã¾ããè¦ç´ ã®æåã®åï¼å
é è¡ã®æåã®é¨åã¨ãªãï¼ãã¤ã³ã©ã¤ã³ãã¼ãã«ãªã©ã®ã¤ã³ã©ã¤ã³ãããã¯ã¬ãã«è¦ç´ ã§ããå ´åã::first-line ã¯å¹æãæã¡ã¾ããã
ã¡ã¢:
Selectors Level 3 ã§ã¯äºéã³ãã³ (::) ãå°å
¥ããæ¬ä¼¼è¦ç´ ãåä¸ã³ãã³ (:) ã®æ¬ä¼¼ã¯ã©ã¹ã¨è¦åãããããã¦ãã¾ãããã©ã¦ã¶ã¼ã¯ ::first-line ã¨ãCSS2 ã§å°å
¥ããã :first-line ã®ä¸¡æ¹ãåãä»ãã¾ãã
CSS ã® background ã®ç®çä¸ã::first-line æ¬ä¼¼è¦ç´ ã¯ã¤ã³ã©ã¤ã³ã¬ãã«è¦ç´ ã¨åæ§ã«æ±ããã¾ããã¤ã¾ããå·¦æãã®å
é è¡ã§ã¯ãèæ¯ãå³ãã¼ã¸ã³ã¾ã§å®å
¨ã«åºãããªãå ´åãããã¾ãã
å©ç¨å¯è½ãªããããã£
::first-line æ¬ä¼¼è¦ç´ ã§ã¯ãä¸é¨ã® CSS ããããã£ã®ã¿ãå©ç¨ã§ãã¾ãã
- ãã©ã³ãã«é¢ããå
¨ããããã£:
font,font-kerning,font-style,font-variant,font-variant-numeric,font-variant-position,font-variant-east-asian,font-variant-caps,font-variant-alternates,font-variant-ligatures,font-synthesis,font-feature-settings,font-language-override,font-weight,font-size,font-size-adjust,font-stretch,font-family - èæ¯ã«é¢ããå
¨ããããã£:
background-color,background-clip,background-image,background-origin,background-position,background-repeat,background-size,background-attachment,background-blend-mode colorããããã£word-spacing,letter-spacing,text-decoration,text-transform,line-heighttext-shadow,text-decoration,text-decoration-color,text-decoration-line,text-decoration-style,vertical-align
æ§æ
::first-line {
/* ... */
}
ä¾
>段è½ã®å é è¡ã®ã¹ã¿ã¤ã«è¨å®
HTML
<p>
ã¹ã¿ã¤ã«ã¯ãã®æ®µè½ã®å
é è¡ã«ã®ã¿é©ç¨ããã¾ãã
ãã®å¾ã®ãã¹ã¦ã®æååã¯æ®éã®ã¹ã¿ã¤ã«ã«ãªãã¾ããåããã¾ããï¼
</p>
<span>
ãããã¯ã¬ãã«è¦ç´ ã§ã¯ãªãã®ã§ããã®æååã®å
é è¡ã¯ãç¹æ®ãªã¹ã¿ã¤ã«ã«ãªãã¾ããã
</span>
CSS
::first-line {
color: blue;
font-weight: bold;
/* è¦å: ãããã使ç¨ããªãã§ãã ãã */
/* ::first-line æ¬ä¼¼è¦ç´ ã§ã¯å¤ãã®ããããã£ãç¡å¹ã«ãªãã¾ã */
margin-left: 20px;
text-indent: 20px;
}
çµæ
SVG ã® text è¦ç´ ã®å é è¡ãã¹ã¿ã¤ã«è¨å®
ãã®ä¾ã§ã¯ãSVG ã® <text> è¦ç´ ã®å
é è¡ã ::first-line æ¬ä¼¼è¦ç´ ã使ç¨ãã¦ã¹ã¿ã¤ã«è¨å®ãã¾ãã
ã¡ã¢: å·çæç¹ã§ããã®æ©è½ã¯å¯¾å¿ãéå®ããã¦ãã¾ãã
HTML
<svg viewBox="0 0 320 150">
<text y="20">Here is an English paragraph
that is broken into multiple lines
in the source code so that it can
be more easily read and edited
in a text editor.
</text>
</svg>
CSS
SVG ã® <text> è¦ç´ ãè¤æ°è¡ã«æãè¿ãã«ã¯ãwhite-space CSS ããããã£ã使ç¨ãã¾ãããã®å¾ã::first-line æ¬ä¼¼è¦ç´ ã§æåã®è¡ã鏿ãã¾ãã
text {
white-space: break-spaces;
}
text::first-line {
fill: blue;
font-weight: bold;
}
çµæ
仿§æ¸
| 仿§æ¸ |
|---|
| CSS Pseudo-Elements Module Level 4 > # first-line-pseudo > |