📜  HTML | DOM 样式 boxShadow 属性

📅  最后修改于: 2021-11-07 09:21:27             🧑  作者: Mango

DOM Style boxShadow属性用于设置返回元素的阴影。

句法:

  • 获取 boxShadow 属性
    object.style.boxShadow
  • 设置 boxShadow 属性
    object.style.boxShadow = "horizontal-offset vertical-offset blur
    spread color inset | none | initial | inherit"

属性值:

  1. 水平偏移垂直偏移:用于以长度单位指定阴影的位置。允许负值。

    示例 1:

    
    
      
    
        
            DOM Style boxShadow
        
      
        
    
      
    
        

          GeeksforGeeks     

               DOM Style boxShadow          

          GeeksforGeeks is a computer science portal       with a huge variety of well written and        explained computer science and programming       articles, quizzes and interview questions.     

                        

    输出:

    点击按钮前:

    偏移前

    点击按钮后:

    偏移后

  2. 模糊:这用于定义要在阴影中使用的模糊量。

    示例 2:

    
    
      
    
        
            DOM Style boxShadow
        
      
        
    
      
    
        

          GeeksforGeeks     

               DOM Style boxShadow          

          GeeksforGeeks is a computer science       portal with a huge variety of well        written and explained computer science       and programming articles, quizzes and       interview questions.     

                        

    输出:

    点击按钮前:

    模糊之前

    点击按钮后:

    模糊之后

  3. 传播:这用于定义阴影的传播量。

    示例 3:

    
    
      
    
        
            DOM Style boxShadow
        
      
        
    
      
    
        

          GeeksforGeeks     

               DOM Style boxShadow          

          GeeksforGeeks is a computer science        portal with a huge variety of well        written and explained computer science        and programming articles, quizzes and       interview questions.     

                        

    输出:

    点击按钮前:

    传播前

    点击按钮后:

    传播后

  4. 颜色:这用于定义要使用的阴影的颜色。

    示例 4:

    
    
      
    
        
            DOM Style boxShadow
        
      
        
    
      
    
        

          GeeksforGeeks     

               DOM Style boxShadow          

          GeeksforGeeks is a computer science        portal with a huge variety of well        written and explained computer science        and programming articles, quizzes and        interview questions.     

                        

    输出:

    点击按钮前:

    上色前

    点击按钮后:

    色后

  5. inset:这用于将阴影设置为内部阴影。通常阴影是一个开始,即在外面。

    示例 5:

    
    
      
    
        
            DOM Style boxShadow
        
      
        
    
      
    
        

          GeeksforGeeks     

               DOM Style boxShadow          

          GeeksforGeeks is a computer science        portal with a huge variety of well        written and explained computer science        and programming articles, quizzes and        interview questions.     

                        

    输出:

    点击按钮前:

    插入前

    点击按钮后:

    插入后

  6. none:这用于删除任何存在的阴影。这是默认值。

    示例 6:

    
    
      
    
        
            DOM Style boxShadow
        
      
        
    
      
    
        

          GeeksforGeeks     

               DOM Style boxShadow          

          GeeksforGeeks is a computer science       portal with a huge variety of well        written and explained computer science        and programming articles, quizzes and        interview questions.     

                        

    输出:

    点击按钮前:

    前所未有

    点击按钮后:

    无后

  7. 初始值:用于将此属性设置为其默认值。

    示例 7:

    
    
      
    
        
            DOM Style boxShadow
        
      
        
    
      
    
        

          GeeksforGeeks     

               DOM Style boxShadow          

          GeeksforGeeks is a computer science        portal with a huge variety of well       written and explained computer science       and programming articles, quizzes and       interview questions.     

                        

    输出:

    点击按钮前:

    初始之前

    点击按钮后:

    初始之后

  8. 继承:这从其父级继承属性。

    示例 8:

    
    
      
    
        
            DOM Style boxShadow
        
      
        
    
      
    
        

          GeeksforGeeks     

               DOM Style boxShadow          
        
        
            

              GeeksforGeeks is a computer science           portal with a huge variety of well            written and explained computer science           and programming articles, quizzes and           interview questions.         

        
        
                        

    输出:

    点击按钮前:

    先继承

    点击按钮后:

    继承

    支持的浏览器: boxShadow属性支持的浏览器如下:

    • 谷歌浏览器
    • 浏览器 9.0
    • 火狐
    • 歌剧
    • 苹果 Safari 5.1.1