1.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>使用css()为图片添加边框</title>
<style>
div{
margin: 0px auto;
width: 400px;
text-align: center;
}
</style>
</head>
<body>
<div id="div"><img src="pic.gif"></div>
<script src="jquery-1.12.4.js" type="text/javascript"></script>
<script>
$(function () {
$("img").click(function () {
$("#div").css({"border":"1px solid"});
})
})
</script>
</body>
</html>
2.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>林徽因简介</title>
<style>
h1{
text-align: center;
color: white;
}
h2{
text-align: center;
color: white;
}
#d1{
background: black;
}
#d2{
margin-top:-10px;
background: black;
}
#p1{
background: white;
text-indent: 2em;
font-size: 30px;
}
#p2{
background: white;
font-size: 30px;
}
</style>
</head>
<body>
<div id="d1">
<h1>
林徽因简介
</h1>
<p id="p1">林徽因,女,汉族,原名林徽音,出生于浙江杭州,祖籍福建福州。中国著名建筑家、诗人、作家。人民英雄纪念碑和中华人民共和国国徽深化方案的设计者
林徽因是建筑师梁思成的第一任妻子。三十年代初,与夫婿梁思成用现代科学方法研究方法研究中国古代建筑,成为这个学术领域的开拓者。</p>
</div>
<div id="d2">
<h2>
主要作品
</h2>
<p id="p2">
《你是人间四月天》<br/>
《宝莲灯》<br/>
《九十九度中》
</p>
</div>
<script type="text/javascript" src="jquery-1.12.4.js"></script>
<script>
$(function () {
$("#p1").hide();
$("#p2").hide();
$("h1").click(function () {
$("#p1").show();
})
$("h2").click(function () {
$("#p2").show();
})
})
</script>
</body>
</html>