先看代码:
<html>
<head>
<style>
body {
margin: 0px;
}
.basediv {
height: 200px;
background-color: aquamarine;
}
.childdiv {
width:60px;
height: 20px;
background-color: red;
/* 自己不生效,却对父div生效 */
margin-top:100px;
}
</style>
</head>
<body>
<div>
<div class="basediv">
<div class="childdiv">
</div>
</div>
</div>
</body>
</html>
点击 这里 查看Demo效果。
找了一些资料发现有些冗余,不够简洁,还是自己写吧。
在操作img标签src属性时用到了jquery,不想用jquery的可以自己想办法去掉。
以下是代码:
python语言定义大段文本,一般都这样写 python code:
str = '''
asdfdfsaasfdsadf--\n ' "
asdf
阿斯蒂芬
'''
print(str)
可是js语法不支持类似语法,但有一些小技巧 js code:
var multiple_string = function() {
var fun = function() {
/*line1
line2
line3
\nline4*/
}
var lines = fun.toString();
lines = lines.substring(lines.indexOf("/*") + 2, lines.lastIndexOf("*/"));
/* 这里只处理一些常见的转义 */
lines = lines.replace(/\\n/g, "\n");
lines = lines.replace(/\\r/g, "\r");
return lines.replace(/\\t/g, "\t");
}();
console.log(multiple_string)
但不幸的是这种奇淫巧技会被代码混淆压缩等工具直接当成普通注释删掉~~~so, 还是尽量少用微妙!
code:
<!DOCTYPE html>
<html>
<head>
<style>
#borderimg1 {
border: 10px solid transparent;
padding: 15px;
-webkit-border-image: url(border.png) 30 round; /* Safari 3.1-5 */
-o-border-image: url(border.png) 30 round; /* Opera 11-12.1 */
border-image: url(border.png) 30 round;
}
#borderimg2 {
border: 10px solid transparent;
padding: 15px;
-webkit-border-image: url(border.png) 30 stretch; /* Safari 3.1-5 */
-o-border-image: url(border.png) 30 stretch; /* Opera 11-12.1 */
border-image: url(border.png) 30 stretch;
}
</style>
</head>
<body>
<p>The border-image property specifies an image to be used as the border around an element:</p>
<p id="borderimg1">Here, the middle sections of the image are repeated to create the border.</p>
<p id="borderimg2">Here, the middle sections of the image are stretched to create the border.</p>
<p>Here is the original image:</p><img src="border.png">
<p><strong>Note:</strong> Internet Explorer 10, and earlier versions, do not support the border-image property.</p>
</body>
</html>
图片素材:
![](https://blog.kyle.net.cn/css-border.png?imageView2/0/q/70 | imageslim) |
参考: https://www.w3schools.com/cssref/css3_pr_border-image.asp
C++返回局部静态对象引用会调用拷贝构造函数吗? 今天佳何从野鸡博客上看了一个c++单例的实现,代码:
static RoomManager& getInstance() {
static RoomManager mgr;
return mgr;
};
Ubuntu Install Nvidia Driver
For Ubuntu 12.04
sudo add-apt-repository ppa:bumblebee/stable
sudo apt-get update
sudo apt-get install bumblebee bumblebee-nvidia virtualgl linux-headers-generic
sudo reboot
For Ubuntu 14.04 and later
sudo apt-get install bumblebee bumblebee-nvidia primus linux-headers-generic
sudo reboot
https://wiki.ubuntu.com/Bumblebee#Installation