题目要求 在 style 标签中按如下要求设置样式 1、id 为bk 的 div元素:背景颜色(#f5f5f5)、下边框(1px、实线、#000000)、边框颜色(#cdcdcd)。(注:先设置下边框,再设置整体边框颜色) 2、id 为 topic 的 div元素:宽度(900px)、外边距(上下外边距0px,左右自适应)、内边距(5px)。 3、id 为title 的p元素:字号(40px)、字体(中宋)、字体粗细(bolder)、宽度(900px) 。 4、id 为 source2的 span 元素:字号(13px)、文本颜色(#ababab)。 5、id 为content 的 div元素:宽度(650px)、外边距(上下外边距0px,左右自适应)、右边框(1px、实线、#efefef)、右内边距(10px)。 6、id 为 feedback 的 p 元素:字号(13px)、文本颜色(#ababab)、占对齐。 7、hr :高度(1px)、无边框、背景颜色(#cdcdcd)。
时间: 2024-04-05 14:33:21 浏览: 131
请按照以下代码设置样式:
```html
<style>
#bk {
background-color: #f5f5f5;
border-bottom: 1px solid #000000;
border-color: #cdcdcd;
}
#topic {
width: 900px;
margin: 0px auto;
padding: 5px;
}
#title p {
font-size: 40px;
font-family: "中宋";
font-weight: bolder;
width: 900px;
}
#source2 {
font-size: 13px;
color: #ababab;
}
#content {
width: 650px;
margin: 0px auto;
border-right: 1px solid #efefef;
padding-right: 10px;
}
#feedback p {
font-size: 13px;
color: #ababab;
text-align: right;
}
hr {
height: 1px;
border: none;
background-color: #cdcdcd;
}
</style>
```
相关问题
对下面的代码加注释:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <style> #backg { width: 919px; height: 272px; } div img { width: 300px; height: 222px; margin-top: 20px; margin-left: 10px; } #h3 { color: rgb(132, 106, 90); font-weight: 600; font-size: 23px; margin-top: -224px; margin-left: 340px; } #p1 { font-size: 14px; color: rgb(20, 111, 158); font-weight: 550; margin-top: 13px; margin-left: 340px; } #p2 { width: 575px; font-size: 13.2px; color: black; text-indent: 2em; margin-top: -3px; margin-left: 340px; } #p2 span { color: rgb(20, 111, 158); font-style: italic; text-decoration: underline; } #p3 { font-size: 14px; color: rgb(20, 111, 158); font-weight: 550; margin-top: 10px; margin-left: 340px; } #p3 span { color: red; font-size: 20px; font-weight: 800; } hr { width: 560px; margin-top: -2px; margin-left: 340px; } #p4 { color: rgb(132, 106, 90); font-weight: 540; font-size: 23px; margin-top: 12px; margin-left: 340px; } #p4 span { color: red; font-weight: 800; } </style> <body> <div id="backg"> <img src="./img/bk01.png" alt=""> <div id="h3">Web前端开发工程师</div> <p id="p1">技术要求:</p> <p id="p2">对常用的一些Js框架了解,如jQuery、YUuI等。掌握最基本的JavaScript计算方法编写。对目前互联网流行的网页制作方法(Web2.0) HTML+CSS,以及各大浏览器兼容性有很大的了解。对前沿技术(HTML5+CSS3)的基本掌握。<span>Web前端技术</span>你究竟掌握了多少...</p> <p id="p3">更新时间:2015年05月19日20点(已有<span>325</span>人点赞)</p> <hr> <p id="p4">相关技术文章 <span>8</span> 篇</p> </div> </body> </html>
```
<!DOCTYPE html> <!--声明文档类型为HTML5-->
<html lang="en"> <!--HTML文档的基本结构,lang属性表示使用的语言为英语-->
<head> <!--网页头部,包含元数据信息和外部资源引用-->
<meta charset="UTF-8"> <!--指定字符编码为UTF-8-->
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <!--告诉IE浏览器采用最新的渲染方式-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <!--设置页面在移动端显示时的视口大小-->
<title>Document</title> <!--网页标题-->
</head>
<style> <!--样式表-->
#backg { <!--id选择器,对应下面的div标签-->
width: 919px; <!--宽度为919像素-->
height: 272px; <!--高度为272像素-->
}
div img { <!--对应上面的图片,设置其样式-->
width: 300px; <!--宽度为300像素-->
height: 222px; <!--高度为222像素-->
margin-top: 20px; <!--上边距为20像素-->
margin-left: 10px; <!--左边距为10像素-->
}
#h3 { <!--id选择器,对应下面的h3标签-->
color: rgb(132, 106, 90); <!--文字颜色为rgb(132, 106, 90)-->
font-weight: 600; <!--字体加粗-->
font-size: 23px; <!--字体大小为23像素-->
margin-top: -224px; <!--设置上边距,将h3标签向上提升224像素-->
margin-left: 340px; <!--左边距为340像素-->
}
#p1 { <!--id选择器,对应下面的p标签-->
font-size: 14px; <!--字体大小为14像素-->
color: rgb(20, 111, 158); <!--文字颜色为rgb(20, 111, 158)-->
font-weight: 550; <!--字体加粗-->
margin-top: 13px; <!--上边距为13像素-->
margin-left: 340px; <!--左边距为340像素-->
}
#p2 { <!--id选择器,对应下面的p标签-->
width: 575px; <!--宽度为575像素-->
font-size: 13.2px; <!--字体大小为13.2像素-->
color: black; <!--文字颜色为黑色-->
text-indent: 2em; <!--段落首行缩进2个字符-->
margin-top: -3px; <!--上边距为-3像素-->
margin-left: 340px; <!--左边距为340像素-->
}
#p2 span { <!--对应上面的span标签,设置其样式-->
color: rgb(20, 111, 158); <!--文字颜色为rgb(20, 111, 158)-->
font-style: italic; <!--字体样式为斜体-->
text-decoration: underline; <!--添加下划线-->
}
#p3 { <!--id选择器,对应下面的p标签-->
font-size: 14px; <!--字体大小为14像素-->
color: rgb(20, 111, 158); <!--文字颜色为rgb(20, 111, 158)-->
font-weight: 550; <!--字体加粗-->
margin-top: 10px; <!--上边距为10像素-->
margin-left: 340px; <!--左边距为340像素-->
}
#p3 span { <!--对应上面的span标签,设置其样式-->
color: red; <!--文字颜色为红色-->
font-size: 20px; <!--字体大小为20像素-->
font-weight: 800; <!--字体加粗-->
}
hr { <!--水平线-->
width: 560px; <!--宽度为560像素-->
margin-top: -2px; <!--上边距为-2像素-->
margin-left: 340px; <!--左边距为340像素-->
}
#p4 { <!--id选择器,对应下面的p标签-->
color: rgb(132, 106, 90); <!--文字颜色为rgb(132, 106, 90)-->
font-weight: 540; <!--字体加粗-->
font-size: 23px; <!--字体大小为23像素-->
margin-top: 12px; <!--上边距为12像素-->
margin-left: 340px; <!--左边距为340像素-->
}
#p4 span { <!--对应上面的span标签,设置其样式-->
color: red; <!--文字颜色为红色-->
font-weight: 800; <!--字体加粗-->
}
</style>
<body> <!--网页主体部分-->
<div id="backg"> <!--div标签,id为backg,用作背景-->
<img src="./img/bk01.png" alt=""> <!--图片,引用地址为./img/bk01.png-->
<div id="h3">Web前端开发工程师</div> <!--h3标题,id为h3-->
<p id="p1">技术要求:</p> <!--段落,id为p1-->
<p id="p2">对常用的一些Js框架了解,如jQuery、YUuI等。掌握最基本的JavaScript计算方法编写。对目前互联网流行的网页制作方法(Web2.0) HTML+CSS,以及各大浏览器兼容性有很大的了解。对前沿技术(HTML5+CSS3)的基本掌握。<span>Web前端技术</span>你究竟掌握了多少...</p> <!--段落,id为p2,包含一个span标签-->
<p id="p3">更新时间:2015年05月19日20点(已有<span>325</span>人点赞)</p> <!--段落,id为p3,包含一个span标签-->
<hr> <!--水平线-->
<p id="p4">相关技术文章 <span>8</span> 篇</p> <!--段落,id为p4,包含一个span标签-->
</div>
</body>
</html>
```
<div class="layui-container"> <div class="hot-sell" v-if="bookAll.length > 0"> <div class="layui-row layui-col-space20"> <table> <tr> <td v-for="(bk,index) in bookAll" :key="index" class="layui-col-xs2" style="margin-left: 30px"> <a :href="'detail?id='+bk.bookId" class="text"> <div><img :src="'/BookShopSystem_war/' + bk.image1"></div> <p>{{bk.bookName}}</p> <p class="price">¥{{bk.bookPrice}}</p> </a> </td> </tr> </table> </div> </div> </div> <div id="houseList"></div> //列表页——分页 layui.use(['laypage'], function () { var laypage = layui.laypage; laypage.render({ elem: 'houseList' , count: 25 , limit: 5 , theme: '#daba91' , layout: ['page', 'next'] }); }); Vue.config.productionTip = false //阻止vue在启动时生成生产提示 new Vue({ el: "#app", data() { return { bookAll: [] } }, mounted() { var _this = this; axios({ method: 'get', url: 'http://localhost:8080/BookShopSystem_war/getBookAll' }).then(function (result) { var code = result.data.code; var data = result.data.data; if (code == 0) { _this.bookAll = data; } console.log(data) }) } })已省略部分代码,数据都可遍历出来,如何实现分页功能
在Vue中实现分页功能可以使用第三方库,比如element-ui和iview等,也可以使用layui等前端框架的自带分页组件。下面给出使用layui的示例代码:
HTML代码:
```
<div class="layui-container">
<div class="hot-sell" v-if="bookAll.length > 0">
<div class="layui-row layui-col-space20">
<table>
<tr>
<td v-for="(bk,index) in currentBookAll" :key="index" class="layui-col-xs2" style="margin-left: 30px">
<a :href="'detail?id='+bk.bookId" class="text">
<div><img :src="'/BookShopSystem_war/' + bk.image1"></div>
<p>{{bk.bookName}}</p>
<p class="price">¥{{bk.bookPrice}}</p>
</a>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="houseList"></div>
```
Vue代码:
```
new Vue({
el: "#app",
data() {
return {
bookAll: [],
currentBookAll: [],
page: {
count: 0,
limit: 5,
curr: 1
}
}
},
mounted() {
var _this = this;
axios({
method: 'get',
url: 'http://localhost:8080/BookShopSystem_war/getBookAll'
}).then(function (result) {
var code = result.data.code;
var data = result.data.data;
if (code == 0) {
_this.bookAll = data;
_this.page.count = Math.ceil(_this.bookAll.length / _this.page.limit);
_this.changePage(1);
}
})
},
methods: {
changePage(curr) {
var start = (curr - 1) * this.page.limit;
var end = curr * this.page.limit;
this.currentBookAll = this.bookAll.slice(start, end);
this.page.curr = curr;
layui.use(['laypage'], function () {
var laypage = layui.laypage;
laypage.render({
elem: 'houseList',
count: this.page.count,
limit: this.page.limit,
curr: this.page.curr,
theme: '#daba91',
layout: ['page', 'next'],
jump: function (obj, first) {
if (!first) {
_this.changePage(obj.curr);
}
}
});
});
}
}
})
```
上述代码中,通过计算总页数和当前页数据的起止索引,实现了分页功能。在changePage方法中,使用slice方法截取当前页的数据,并通过laypage组件渲染分页控件。在laypage的jump回调函数中,调用changePage方法更新当前页数据。
阅读全文
相关推荐
















