css失效_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:22:39
Original
947 people have browsed it

CSS

我在页面里边 写了个内联style   但是用js加载新的html的时候class对应了也没有效果  有什么原因可能出现这问题的么 

回复讨论(解决方案)

1.看下是不是有js修改了样式
2.样式表是否有正确加载
3.看下内联样式是否有写正确
4.一段段代码排除分析,看下是哪段有问题

1.看下是不是有js修改了样式
2.样式表是否有正确加载
3.看下内联样式是否有写正确
4.一段段代码排除分析,看下是哪段有问题

 我的js没有修改样式,只是加载html ;第一次加载的时候是可以的 不过我点击再次加载的时候 样式就失效了  ;js加载html有什么要注意的么


1.看下是不是有js修改了样式
2.样式表是否有正确加载
3.看下内联样式是否有写正确
4.一段段代码排除分析,看下是哪段有问题

 我的js没有修改样式,只是加载html ;第一次加载的时候是可以的 不过我点击再次加载的时候 样式就失效了  ;js加载html有什么要注意的么


第一次加载的时候是可以的 不过我点击再次加载的时候 样式就失效了(你把第一次加载可以的原码和第二次再加载失效的原码对比下,看下有什么不同的地方)

js加载html没有什么要特别注意的地方,写法正确,路径写对就行了

中写的样式?

确认是不是写的“.class”
确认是不是被直接写在元素上的样式覆盖


1.看下是不是有js修改了样式
2.样式表是否有正确加载
3.看下内联样式是否有写正确
4.一段段代码排除分析,看下是哪段有问题

 我的js没有修改样式,只是加载html ;第一次加载的时候是可以的 不过我点击再次加载的时候 样式就失效了  ;js加载html有什么要注意的么

用chrome或者firebug点击审查元素,可以看到动态加载后的DOM结构,对比一下就可以区分了。

建议你把代码贴出来大家看看

中写的样式?

确认是不是写的“.class”
确认是不是被直接写在元素上的样式覆盖

对 写在style里边
 dom结构是一样的,我也用chrome审查元素看过了   只是js加载过其他数据

建议你把代码贴出来大家看看

代码比较长 不好贴


中写的样式?

确认是不是写的“.class”
确认是不是被直接写在元素上的样式覆盖

对 写在style里边
 dom结构是一样的,我也用chrome审查元素看过了   只是js加载过其他数据
右栏那里的styles列表没有加载还是被覆盖?


建议你把代码贴出来大家看看

代码比较长 不好贴

是个日历的   

 


        //table += ('

'+monthNames[month]+' '+year+'

');
        table += ('
');
        table += ('     
');
        table += ('     
');
        table += monthNames[month] + ' ' + year;
        table += ('     
');
        table += ('     
>
');
        table += ('
');
        // uncomment the following lines if you'd like to display calendar month based on 'month' and 'view' paramaters from the URL
        //table += ('
'+ prev_month +'
');
        //table += ('
'+ next_month +'
');
        table += ('');

        table += '';

        for (d = 0; d              table += '';
        }

        table += '';

        var days = getDaysInMonth(month, year);
        var firstDayDate = new Date(year, month, 1);
        var firstDay = firstDayDate.getDay();

        var prev_days = getDaysInMonth(month, year);
        var firstDayDate = new Date(year, month, 1);
        var firstDay = firstDayDate.getDay();

        var prev_m = month == 0 ? 11 : month - 1;
        var prev_y = prev_m == 11 ? year - 1 : year;
        var prev_days = getDaysInMonth(prev_m, prev_y);
        firstDay = (firstDay == 0 && firstDayDate) ? 7 : firstDay;

        var i = 0;
        var tempDate = "";
        for (j = 0; j 
            if ((j                  //pre month
                table += ('                 table += ('"');
                tempDate = prevYear.toString() + '-' + (prevMonth).toString() + '-' + (prev_days - firstDay + j + 1).toString();
                table += (' onclick=\"javascript:$.fn.dateevent(\'' + tempDate + '\');\"');
                table += ('>');
                table += ('' + (prev_days - firstDay + j + 1) + '');
            } else if ((j >= firstDay + getDaysInMonth(month, year))) {
                //next month
                i = i + 1;
                table += ('                 table += ('"');
                table += (' onclick=\"javascript:$.fn.dateevent(\'' + nextYear.toString() + '-' + (nextMonth).toString() + '-' + i.toString() + '\');\"');
                table += ('>');
                table += ('                 table += ('dayOther"')
                table += ('>');
                table += i;
                table += ('');
            } else {
                //now month
                table += ('                 if (thismonth == month && thisDay == (j - firstDay + 1)) {
                    table += (' dayActive');
                }
                else {
                    table += ('  current-month daysCss');
                }
                table += ('"');
                table += (' onclick=\"javascript:$.fn.dateevent(\'' + year.toString() + '-' + (month + 1).toString() + '-' + (j - firstDay + 1).toString() + '\');\"');
                table += ('>');
                table += ('                 table += ('day"')
                table += ('>');
                table += (j - firstDay + 1);
                table += ('');
            }
            if (j % 7 == 6) table += ('');
        }

        table += ('
' + dayNames[d] + '
');
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!