js修改伪类元素样式
<style type="text/css">
.htmlbox_close::before,
.htmlbox_close::after {
content: '';
position: absolute;
height: 2px;
top: 4%;
width: 3%;
left: 2%;
margin-top: -1px;
background: #51aed9;
height: 1.1%;
}
.htmlbox_close::before {
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
.htmlbox_close::after {
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
}
</style>
</head>
<body>
<div class="htmlbox_close"></div>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
var str = window.getComputedStyle($('.htmlbox_close')[0], '::before').getPropertyValue('top');
console.log(str);
document.styleSheets[0].addRule('.htmlbox_close::before', 'top:100px');
document.styleSheets[0].insertRule('.htmlbox_close::before { top:100px }', 0);
document.styleSheets[0].addRule('.htmlbox_close::after', 'top:100px');
document.styleSheets[0].insertRule('.htmlbox_close::before { top:100px }', 0);
var str2 = window.getComputedStyle($('.htmlbox_close')[0], '::before').getPropertyValue('top');
console.log(str2);
</script>
</body>
js修改伪类元素样式的更多相关文章
- js修改伪类的值
css文件 p.change:after { content: attr(data-content); } js文件 $(this).addClass('change').attr('data-con ...
- 关于伪类元素:before和:after
关于伪类元素:before和:after CSS中存在一些比较特殊的属性,称之为伪类,它们之中最常用的就是定义链接的伪 :link:未被访问状态 :visited:已被访问状态 :hover:鼠标 ...
- css伪类元素:after 的多功能用法——任意大小的底边框
需求用法出现的背景: 由于项目UI的优化,项目中所有tab导航选中的状态都是统一样式书写的,之前都是用的border-bottom,新的需求如果用以前的本办法就是定位一个选中边框在底部,但是涉及的模板 ...
- 玩转CSS3,嗨翻WEB前端,CSS3伪类元素详解/深入浅出[原创][5+3时代]
在我的上一篇博客中, 很多园友提出说对css3"画图"不是很理解, 在跟他们私聊了一段时间以后,加上自己在开始自学css3的时候的疑惑,我觉得大家之所以不是很理解主要是因为对伪元素 ...
- 用一个例子学习CSS的伪类元素
CSS伪类元素是一个非常酷的东西!首先我们理解一下它,:before :after 伪类元素,也就是虚假的元素.它可以插入在元素的前面或者后面,而在HTML文档结构中,它却是不存在的,因为Js是无法通 ...
- button不能添加伪类元素
今日试了一下button添加伪类元素,结果是不行的前后都叠加在一起 html代码: <button class="form_btn" formType="submi ...
- CSS样式学习-3、轮廓、伪类/元素、display-flex布局
一.轮廓 outline绘制于元素周围的一条线,位于边框边缘外围. 属性规定元素轮廓的样式.颜色.宽度. outline-width轮廓宽度,属性:thin细轮廓.medium中等(默认值).thic ...
- 伪类元素before&after
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- js修改文档的样式
<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Java ...
随机推荐
- 租户、租户管理员、部门管理员和开发者在APIGW中的角色
一.参与者 1.vdcId:租户 2.运营管理员 operator: 一种角色 创建开发商 审批外置服务,如:hadoop集群 审批内置服务,如:<API使用申请> 3.租户管理员 ...
- linux下的Shell编程(8)自定义函数
Shell Script中也可以使用自定义的函数,其语法形式如下: functionname() { - }
- Javascript 判断传入的两个数组是否相似
任务描述: 请在index.html文件中,编写arraysSimilar函数,实现判断传入的两个数组是否相似.具体需求: 1. 数组中的成员类型相同,顺序可以不同.例如[1, true] 与 [fa ...
- python/零起点(一、列表)
python/零起点(一.列表) 列表(list)list()可以强行转换数据类型为列表,列表是可迭代对象 列表是有序的,且列表是可变的数据类型 列表中的元素可以是(字符串.整型.元祖.列表.字典.集 ...
- API之实用工具Postman 使用方法
测试接口与文档信息文件 Postman 安装与入门教程 下载与安装 官方网站:www.getpostman.com 下载完成后,直接安装 输入2次邮箱,密码,即可注册并登陆! 开发者使用: 创建文件夹 ...
- Struts(十五):主题
Theme主题是配置的struts-core.jar下的com.apache.struts2包下的default.properties中(默认配置为:xhtml) ### Standard UI th ...
- in成员资格符
#in成员资格符 name='小树' '小'in name# 返回True '大树'in name#返回False
- 【转】cookielib模块
cookielib模块 cookielib模块的主要作用是提供可存储cookie的对象,以便于与urllib2模块配合使用来访问Internet资源.例如可以利用本模块 的CookieJar类的对象来 ...
- [LeetCode] Delete Operation for Two Strings 两个字符串的删除操作
Given two words word1 and word2, find the minimum number of steps required to make word1 and word2 t ...
- [LeetCode] Fraction Addition and Subtraction 分数加减法
Given a string representing an expression of fraction addition and subtraction, you need to return t ...