Movatterモバイル変換


[0]ホーム

URL:


Menu
×
See More 
Sign In
+1 Get Certified Upgrade For Teachers Spaces Get Certified Upgrade For Teachers Spaces
   ❮     
     ❯   

CSS Tutorial

CSS HOMECSS IntroductionCSS SyntaxCSS SelectorsCSS How ToCSS CommentsCSS ErrorsCSS ColorsCSS BackgroundsCSS BordersCSS MarginsCSS PaddingCSS Height/WidthCSS Box ModelCSS OutlineCSS TextCSS FontsCSS IconsCSS LinksCSS ListsCSS TablesCSS DisplayCSS Max-widthCSS PositionCSS Z-indexCSS OverflowCSS FloatCSS Inline-blockCSS AlignCSS CombinatorsCSS Pseudo-classesCSS Pseudo-elementsCSS OpacityCSS Navigation BarsCSS DropdownsCSS Image GalleryCSS Image SpritesCSS Attr SelectorsCSS FormsCSS CountersCSS UnitsCSS InheritanceCSS SpecificityCSS !importantCSS Math FunctionsCSS OptimizationCSS AccessibilityCSS Website Layout

CSS Advanced

CSS Rounded CornersCSS Border ImagesCSS BackgroundsCSS ColorsCSS Color KeywordsCSS GradientsCSS ShadowsCSS Text EffectsCSS Custom FontsCSS 2D TransformsCSS 3D TransformsCSS TransitionsCSS AnimationsCSS TooltipsCSS Image StylingCSS Image ModalCSS Image CenteringCSS Image FiltersCSS Image ShapesCSS object-fitCSS object-positionCSS MaskingCSS ButtonsCSS PaginationCSS Multiple ColumnsCSS User InterfaceCSS VariablesCSS @propertyCSS Box SizingCSS Media QueriesCSS MQ Examples

CSS Flexbox

Flexbox IntroFlex ContainerFlex ItemsFlex Responsive

CSS Grid

Grid IntroGrid ContainerGrid ItemsGrid 12-column LayoutCSS @supports

CSS Responsive

RWD IntroRWD ViewportRWD Grid ViewRWD Media QueriesRWD ImagesRWD VideosRWD FrameworksRWD Templates

CSS SASS

SASS Tutorial

CSS Examples

CSS TemplatesCSS ExamplesCSS EditorCSS SnippetsCSS QuizCSS ExercisesCSS WebsiteCSS SyllabusCSS Study PlanCSS Interview PrepCSS BootcampCSS Certificate

CSS References

CSS ReferenceCSS SelectorsCSS CombinatorsCSS Pseudo-classesCSS Pseudo-elementsCSS At-rulesCSS FunctionsCSS Reference AuralCSS Web Safe FontsCSS AnimatableCSS UnitsCSS PX-EM ConverterCSS ColorsCSS Color ValuesCSS Default ValuesCSS Browser Support

CSSBox Shadow


CSS box-shadow Property

The CSSbox-shadow property is used to apply one or more shadows to an element.

In its simplest use, you can only specify the horizontal and the vertical offset of the shadow.

In addition, you can add a shadow color, a spread radius, a blur effect, and change the shadow from an outer shadow to an inner shadow (inset).


CSS Horizontal and Vertical Shadow

In its simplest use, you only specify the horizontal and the vertical offset of the shadow.

The default color of the shadow is the current text color.

A <div> element with a box-shadow

Example

Specify a horizontal and a vertical shadow:

div{
  box-shadow: 10px 10px;
}
Try it Yourself »

Specify a Color for the Shadow

Thecolor parameter defines the color of the shadow.

A <div> element with a lightblue box-shadow

Example

Specify a color for the shadow:

div{
  box-shadow: 10px 10px lightblue;
}
Try it Yourself »


Add a Blur Effect to the Shadow

Theblur parameter defines the blur radius of the shadow. The higher the number, the more blurred the shadow will be.

A <div> element with a 5px blurred, lightblue box-shadow

Example

Add a blur effect to the shadow:

div{
  box-shadow: 10px 10px 5px lightblue;
}
Try it Yourself »

Set the Spread Radius of the Shadow

Thespread parameter defines the spread radius of the shadow.

A positive value increases the size of the shadow, and a negative value decreases the size of the shadow.

A <div> element with a blurred, lightblue box-shadow, with a spread radius of 12px

Example

Set the spread radius of the shadow:

div{
  box-shadow: 10px 10px 5px 12px lightblue;
}
Try it Yourself »

Set the inset Parameter

Theinset parameter changes the shadow from an outer shadow (outset) to an inner shadow (inside an element's frame).

A <div> element with a blurred, lightblue, inset box-shadow

Example

Add the inset parameter:

div{
  box-shadow: 10px 10px 5px lightblue inset;
}
Try it Yourself »

Add Multiple Shadows

An element can also have multiple shadows.

To attach more than one shadow to an element, add a comma-separated list of shadows.

A <div> element with multiple shadows

Example

div{
  box-shadow: 5px 5px 8px blue, 10px 10px 8px red, 15px 15px 8px green;
}
Try it Yourself »

Creating Shadow Cards

You can also use thebox-shadow property to create paper-like cards:

1

January 1, 2021

Norway

Hardanger, Norway

Example

div.card{
  width: 250px;
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  text-align: center;
}
Try it (Text Card) »Try it (Image Card) »


CSS Shadow Properties

The following table lists the CSS shadow properties:

PropertyDescription
box-shadowAdds one or more shadows to an element
text-shadowAdds one or more shadows to a text


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted ourterms of use,cookies andprivacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved.W3Schools is Powered by W3.CSS.


[8]ページ先頭

©2009-2025 Movatter.jp