老项目前端样式直接对h3这个标签设置了样式,现在导致发表的文章内容里面如果有h3标签的话,也会受这个全局样式影响,现在能知道的是文章内容外面的div有个id属性,值为 ac_content ,如果不去
顺晟科技
2021-06-16 10:21:41
267
超文本标记语言
html部分比较简单,声明一个p,具体的html是用javascript生成的。整体内容大概是这样的:
!doctypehtml
超文本标记语言
头
metacharset='utf-8 '
Linkrel='样式表' href='外部css文件路径'/
标题演示/标题
/head
身体
p class=' calendar ' id=' calendar '/p
脚本类型=' text/JavaScript ' src=' external JavaScript文件路径'/script
/body
/html
钢性铸铁
/*整体设置*/
* { margin:0pxpadding:0px}
/**
*设置日历的大小
*/。日历{
宽度width:240px
height:400px
display:block
}
/**
*设置日历的顶部框
*/
日历。日历-标题-框{
位置:相对;
宽度:;
height:36px
行高:36 px;
text-align : center;
border-bottom :1 pxsolid # DDD;
}
/**
*设置上个月的按钮图标
*/
. calendar.prev-month{
position:absolute值;
top:12px
left:0px
display : inline-block;
width:0px
height:0px
border-left :0 px;
border-top :6 pxsolid transparent;
border-right :8 pxsolid # 999;
border-bottom :6 pxsolid transparent;
cursor:pointer指针;
}
/**
*设置下个月的按钮图标
*/
日历下个月
position:absolute值;
top:12px
right:0px
display : inline-block;
width:0px
height:0px
border-right :0 px;
border-top :6 pxsolid transparent;
border-left :8 pxsolid # 999;
border-bottom :6 pxsolid transparent;
cursor:pointer指针;
}
/*设置日历表格样式*/。日历-表格{
宽度:;
边界塌陷;
text-align : center;
}
/*表格行高*/。日历-桌面{
height:30px
行高:30 px;
}
/*当天颜色的特殊显示*/。当前日期{
color:red
}
/*本月文本颜色*/。当前月{
color: # 999
}
/*其他月份的颜色*/。其他月份{
color: # ede
}
风格设置基本没有讲座,只是一些简单的设置。比如特殊的图标有“上个月”和“下个月”,采用定位,利用css中的边框属性来设置样式。
JavascriptDate对象
在开始正式的js代码之前,您需要知道js中的Date对象。通过Date对象,可以获得年、月、日、分、时间戳等信息。
var D1=NewDate();//获取当前系统时间。我现在的时间是2016年4月25日星期一
D1 . GetFullyear();//获取年份信息,2016
D1 . getmonth();//获取每月信息(从0开始,范围:0-11)3
D1 . GetDate();//获取日信息。此处结果:25
D1 . GetDay();//获取周信息(0-6)。结果如下:1
也可以在初始化时直接设置年、月、日信息
#设定2016年3月15日
vard2=newDate(2016,2,15);//月从0开始计数,需要减1
D2 . GetFullyear();//2016
D2 . getmonth();//2
D2 . GetDate();//15
D2 . ToLocaledateString();//' 2016年3月15日'证明设置正确
日历会涉及每月几天等问题。在js里面很简单。如果日期设置在当月之后,js会自动将其计算为下个月。比如4月份只有30天。如果设置为31,则得到的日期类型会自动计算为5月1日;如果设置为5月0日,js将处理为4月30日,那么5月1日就是4月29日
vard3=newDate(2016,3,30);
D3 . tolocaledatestring();//'2016/4/30'
vard4=newDate(2016,3,31);
D4 . tolocaledatestring();//'2016/5/1'
vard5=newDate(2016,3,33);
D5 . ToLocaledateString();//'2016/5/3'
vard6=newDate(2016,4,1);
D6 . ToLocaledateString();//'2016/5/1'
vard7=newDate(2016,4,0);
D7 . tolocaledatastring();//'2016/4/30'
vard8=newDate(2016,4,-3);
D8 . tolocaledatestring();//'2016/4/27'
java描述语言
了解了js中Date对象的基本用法后,接下来就是代码实现了。整个思路是这样的:定义一个全局的dateObj变量,记录要在表中显示的年、月信息。标题中的内容是从dateObj中检索出来的,而年份和月份对应的1号的所有信息都是从表格中的dateObj中检索出来的,这样就可以确定1号在表格行的位置,从而向后推上个月最后几天的数据,向前推这个月和下个月的数据。
具体步骤:
1.声明dateObj变量,并将初始值赋给当前系统时间
2.在calendarp中渲染html元素。
3.通过dateObj获取当月天的信息,遍历表中所有日期
4.什么~我爱你~范思哲是范思哲吗
(函数()
/*
*范仲景范仲裁庭,1740年,-什么给目标文件我的意思是,我的意思是,我的意思是,我的意思是,我的意思是,我的意思是,我的意思是,我的意思是,我的意思是,我的意思是,我的意思是,我的意思是,我的意思是,我的意思是,我的意思是
*/
vardata obj=(function())与[
var_date=newDate()://黄警司,黄警司
返回
get data 3330 function()=>
返回日期:
},
setdate :函数(date)}
_日期=日期:
}
}:
})();
//沙吾提日历菲律宾共和国绿筠超文本标记语言格式你好
render html();
//安其林安其林安其林安其林
showcalendardata():
//老伯伯
bind event();
/**
*阿云超文本标记语言格式朱穆伟
*/
functionrenderHtml()
varcalendar=document。getelement byid(' calendar ');
vartitlex=document。创建元素(' p ');//你是说.
varbody box=document。创建元素(' p ');//吴亚玲吴亚玲
//(英文)html格式
titlex。class name=' calendar-title box ';
标题栏。intra tml=' span class=' pre-month ' id=' pre-month '/span '
span class=' calendar-title ' id=' calendar title '/span '
西班牙语='下月' class='下月'/span ';
日历。附录儿童(title bo);//吴秀喜日历菲律宾共和国何曰
//吴惠玲,吴惠玲,吴惠玲,吴惠玲,吴惠玲,吴惠玲,吴惠玲,吴惠玲,吴惠玲,吴惠玲,吴惠玲,吴惠玲,吴惠玲,吴惠玲,吴惠玲,吴惠玲,吴惠玲超文本标记语言格式朱穆伟
尸体箱。class name=' calendar-body box ';
var_headHtml='tr '
th '什么事/th
th '/th
th '僧儿/th
976年年/th
th '你好/th
th '俊儿/th
th '菲儿/th
/tr ';
var _ body html=';
//魏冄31噢,天啊,拜占庭拜占庭拜占庭6贺盛瑞
对于(杂项=0);i6;(一)>
_bodyHtml='tr '
" td/td "
" td/td "
" td/td "
" td/td "
" td/td "
" td/td "
" td/td "
/tr ';
}
尸体箱。intra tml=' table id=' calendar ' class=' calendar-table '
_headHtml _bodyHtml
/table ';
//吴秀喜日历菲律宾共和国何曰
日历。附录子(车身箱);
}
/**
*阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔阿叔,1826年
*/
functionshowcalendada()>
var_year=dateObj.getDate().get full year();
var_month=dateObj.getDate().get on th()1;
var _ datestr=getdate str(dateobj。getdate());
//不,不,不,不,不,不,不,不,不,不,不,不,不,不,不,不,不,不,不,不,不,不,不,不,不,不,不,不,不,不,不,不,不~我爱你~阿祖
varcalendartitle=document。get element byid(' calendar title ');
vartitles=_ datestr。substr(0,4)"-什么_dateStr.substr(4,2)'-你好";
calendarmet。intratext=title titles
//范仲淹,范仲淹,范仲淹,范仲淹,范仲淹,范仲淹,范仲淹,范仲淹,范仲淹,范仲淹,范仲淹,范仲淹,范仲淹,范仲淹,范仲淹,范仲淹,范仲淹,范仲淹,范仲淹,范仲淹
var _ table=document。获取元素byid(' calendable '):
var _ TDS=_ table。get元素sbytagname(' TD ');
var_firstDay=newDate(_year,_ month-1.1)://哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟
对于(杂项=0);S7-1200可编程控制器:(一)>
var_thisDay=newDate(_year,_month-1,i1-_ first day。getday());
var _ this day str=get data str(_ this day);
_tds[i].intratext=_ this day。getdate();
/_tds[i].data=_ thisdaystr
_tds[i].箭头属性(' data ',_ this day str);
if(_ this day str==get data str(new date())){//哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟
_tds[i].classname=' currentday
} else if(_ thishdaystr . substr(0,6)==getDateStr(_firstDay).substr(0.6))>
_tds[i].classname=' currentmonth//哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟哟
}else{//魏冄
_tds[i].classname=' othermonth
}
}
}
/**
*老魏老陈
*/
函数bindevent()>
varprev month=document。getelement byid(' pre month ');
varextmonth=document。获取元素byid('下个月'):
添加事件(上一个月、单击、上一个月):
addEvent(下个月,点击,到下个月);
}
/**
*老伯伯
*/
函数名
if(DOM。addevent listener){//DOM 2.0
dom.addEventListener(类型、函数)
func(e);
});
-伊甸园字幕组=-翻译
DOM。attach(' on '类型,function(e)
func(e);
});
}else{//DOM0中
DOM[' on ' type]=函数(e)}
func(e);
}
}
}
/**
*朱塞佩朱塞佩朱塞佩朱塞佩
*/
functiontoprev month(){ }
vardate=dateobj。getdate():
dateobj。setdate(newdate(date。getfullyear()、date.getMonth()-1,1));
showcalendardata():
}
/**
*安祖儿安祖儿安祖儿安祖儿
*/
functiontonextmonth()
vardate=dateobj。getdate():
dateobj。setdate(newdate(date。getfullyear()、date . getmonth()(1,1));
showcalendardata():
}
/**
*你是谁,4云娥2魏冄2俊儿
*/
functiongetDateStr(日期)>
var _ year=date。get full year();
var_month=date.getMonth() 1://阿力0啁啾
var _ d=日期。getdate();
_月=(_月9)?(' _ month)3330(' 0 " _ month ");
_d=(_d9)?(' _ d)3360(' 0 ' _ d ');
return_year _month _d:
}
})();
范登韦恩佐范登韦恩佐范登韦恩佐范登韦恩佐,阿巧结缔婚范仲淹是因为范仲淹是因为范仲淹是因为范仲淹的缘故
vartable=document。getelement byid(' calendable ');
vartds=table。getelement sbytagnname(' TD ');
for(vari=0;itds.lengthi ){
addEvent(tds[i],' click ',function(e){
控制台。日志(例如目标。GetAttribute(' data ');
});
}
本文转载自中文网
19
2022-10
25
2022-09
15
2022-09
15
2022-09
15
2022-09
15
2022-09