【问题标题】:Box-Shadow Won't work on my websiteBox-Shadow 在我的网站上不起作用
【发布时间】:2015-01-02 20:14:02
【问题描述】:

尝试在我的网站上显示图像效果时,它们不会显示。 如果我在 jsfiddle.net 上运行图像,它工作得很好。但是,当我在所有代码中对其进行测试时,我的图像不起作用。我想要图像周围的边框阴影效果。执行此操作的代码在我的代码中,但正如您在我的网站图像中看到的那样,没有阴影。

这是我在没有图像的 jsfiddle.net 中测试它时的图像。

我的代码:

CSS:

#collage-container {

        /*width: 699px;*/
        width: 800px;
        /*height: 510px;*/
        height: 320px;
        float: left;
        margin-left: 200px;
        margin-top: 10px;
        background-color: #DADADA;
    }

    #collage-one{

    width: 699px;
    height: 300px;
    margin-left: 50px;
    margin-top: 10px;
    box-shadow: 0 0 20px black;
    }

HTML:

<div id = "collage-container">
    <img src = "longblue.jpg" id = "collage-one"/>
    </div>

更新:这是我所有的 css

       <head>

   <style type = "text/css">


    /* Formating for body of Web Site */
    * {margin: 0; padding: 0;}
    body {
     font-family: times new roman;
     background-color: #ebebeb;


     }

    /* Fixed screen size so objects don't shift */
     #screen {
     /*
     min-width: 768px;
     min-height: 100% !important;
     margin-bottom: 30px;
     */
     /* This locks everything in place*/
     top:0px;
     margin: 0 auto; 
     width:1500px;
     height: 100%;
         padding-top:0;
         padding-bottom: 30px;
         margin-bottom: 150px;
         postion: absolute;
     margin-left: 70px;

     }

    /* Format for black strip header  */
     #header {
        background-color: black;
        height: 168px;
        width: 100%;
        position: relative;
     }

    /* Class1: Holds the navigation buttons in header   */
    .container {
        width: 960px;
        height: auto;
        margin: 0 auto;
        margin-left: 0;
    }

    /* Class2: Holds the small containers for short articles   */
    .containerShort {
                width: 480px;
                height: auto;
                margin: 0 auto;
    }

    /* Sub Classes: For Class2  */
    .short1 {

        right: 30px;
    }

    .short2 {
        right: 30px;

    }

    /* Format for Tree logo in header   */
    #logoArea {
        width: 300px;
        height: 168px;
        background-image: url(treesmall.jpg);
        float: left;
        margin-left: 30px;
        }

    /* Formating for location of navagation buttons  */
    #navArea
    {
        height: 100%;
        float: right;
        margin-right: 0px;
        margin-top: 80px;
        margin-left: 100px;


    }

    /* Removes the bullets for navagation buttons in header  */
    #nav
    {
        list-style: none;

    }

    /* Navagation formating */
    #nav a
    {
        color: white;
        text-decoration: none; /*removes underline*/

    }

    /* Formats the links of navagation buttons   */
    #nav li
    {
        float: left;
        margin-left: 60px;
        background-color: #252525;
        padding: 8px;
        bording: 1px solid silver;
        border-radius: 5px;

    }

    /* Makes a hovering effect where when the mouse hovers over the 
     links they change color  */
    #nav li:hover
    {
        background-color: gray;
    }

    /* Sub class formating for container class  */
    .page
    {
        background-color: white;
        padding: 10px;
        margin-top: 10px;
        width: 1100px;
        float: right;
        border-radius: 5px;
        padding-bottom: 1px;

    }

    /* Side quote article main page */
    .article
            {
                background-color: #ebebeb;
                padding-top: 1px;
                margin-top: 20px;
                width: 120px;
                float: right;
                border-radius: 20px;
                height: 300px;
                border: 1px solid black;
                margin-right: 20px;
                text-align: left;

    }

    /* Formating for left sidebar of information  */
    #sidebar {

    background-color: #B4B4B4;
    height: auto;
    width:350px;
    float:left;
    margin-top: 10px;
    border-radius: 5px;
    padding: 10px;
    color: #483D8B;
    }

    /* footer formating  */
    #footer {

        background-color: black;
        height: 40px;
        width: 1500px;
        color: white;
        padding-top: 10px;
        position: relative center;
        bottom: 0;
        text-align: center;
        margin-left:70px;
    }
    /* Formating of Header quote   */
    #quote {
        color: white;
        float: right;
    }

    /* Paragraph formating  */
    p {
        color: black;
        margin-bottom: 20px;
        padding: 5px;
        padding-left: 40px;
    }

    p.light {

    color: white !important;
    margin-bottom: 60px;
    padding: 5px;
    padding-left: 40px;

    }

    p .imagespace {

    padding-left: 40px;
    margin: auto;
    }

    h3 {
        margin-bottom: 60px;
    }

    h2 {

    font-family: "Times New Roman";
    font-style: oblique;
    }

    #collage-container {

        /*width: 699px;*/
        width: 800px;
        /*height: 510px;*/
        height: 320px;
        float: left;
        margin-left: 200px;
        margin-top: 10px;
        background-color: #DADADA;
    }

    #collage-one{

    width: 699px;
    height: 300px;
    margin-left: 50px;
    margin-top: 10px;
    box-shadow: 0 0 20px black;
    }

    /*#collage-two,#collage-three,
    #collage-four{

    width: 226px;
    height: 200px;
    padding: 5px;
    background-color: black;
    background-position: top center;
    float: right;

    }*/

    /*#space {

    width:300px;
    height: 508px;
    background-color: white;
    float: left;
    margin-top: 0;
    margin-left: 120px;
     box-shadow: hshadow, vshadow blur color 
    box-shadow: 10px 0 20px #B4B4B4;
    border-radius: 10px;
    }*/

    #ego {
    box-shadow: 0 0 20px #B4B4B4;
    }

    #marquee{

    color: #483D8B;
    margin-top: 10px;
    margin-bottom: 0px;
    width: 1025px;
    float: right;

    }





   </style>

   </head>

【问题讨论】:

  • 如您所述,在带有 Chrome 的 JSFiddle 上运行良好。
  • 是的,我似乎总是遇到这样的问题,在我测试时它可以工作,但在我的页面中实现时却没有。
  • 我们需要查看您网站的 CSS,因为很容易有一些东西会覆盖您的样式。
  • 您在哪个浏览器上查看此内容?您需要为所有浏览器支持使用几个 CSS 属性:css-tricks.com/almanac/properties/b/box-shadow
  • @Phillips126 只要 OP 不使用 IE8 或更少,它们就可以使用。

标签: html css image shadow


【解决方案1】:

根据 cmets 中的建议,看来我必须修复我的影子才能接受更多浏览器版本。

感谢大家一起玩。

主要帮助:@Phillips126

【讨论】:

  • 如果您不介意我问,您使用的是哪个版本的 IE?正如@hungerstar 所提到的,IE 的更高版本包括更多的 CSS 支持。
  • 我不知道我有哪一个。并试图让你的例子起作用......他们不接受它们 LOL
  • @Phillips126 哦,它的版本:10.0.9200.17148
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-11-08
  • 1970-01-01
  • 2023-01-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多