title_font = {'size': 16, 'color': 'red', 'weight': 'bold'} 中的weithgt
时间: 2024-01-18 13:04:30 浏览: 16
在这个例子中,'weight'是指字体的粗细程度。可以设置为以下值之一:
- 'normal':普通字体(默认值)
- 'bold':粗体
- 'bolder':更粗的字体
- 'lighter':更细的字体
- 数字值:100、200、300、400、500、600、700、800或900之一,表示字体粗细的程度。
在这个例子中,'weight': 'bold'表示将字体设置为粗体。
相关问题
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> #box>div { height: 50px; width: 50px; border-radius: 50%; line-height: 50px; text-align: center; font-size: 20px; font-weight: bold; color: white; margin: 10px; float: left; } .red { background-color: red; } .blue { background-color: blue; } </style> </head> <body> <div id="box"> </div> <script> </script> </body> </html>根据此HTML写出双色球选号js部分
以下是双色球选号的js部分:
```javascript
let redBalls = []; //红球数组
let blueBall = 0; //蓝球
//生成红球随机数
function generateRedBall() {
let redBall = Math.floor(Math.random() * 33) + 1;
if (redBalls.includes(redBall)) { //如果随机数已经存在,重新生成
return generateRedBall();
} else {
redBalls.push(redBall);
}
}
//生成蓝球随机数
function generateBlueBall() {
blueBall = Math.floor(Math.random() * 16) + 1;
}
//生成双色球号码
function generateSSQ() {
redBalls = []; //清空红球数组
for (let i = 0; i < 6; i++) {
generateRedBall(); //生成6个红球
}
redBalls.sort((a, b) => a - b); //按升序排序
generateBlueBall(); //生成一个蓝球
displaySSQ(); //显示双色球号码
}
//显示双色球号码
function displaySSQ() {
let box = document.querySelector('#box');
box.innerHTML = ''; //清空盒子
redBalls.forEach(ball => { //显示红球
let div = document.createElement('div');
div.classList.add('red');
div.innerText = ball;
box.appendChild(div);
});
let div = document.createElement('div'); //显示蓝球
div.classList.add('blue');
div.innerText = blueBall;
box.appendChild(div);
}
//点击按钮生成双色球号码
let btn = document.createElement('button');
btn.innerText = '生成双色球号码';
btn.addEventListener('click', generateSSQ);
document.body.appendChild(btn);
```
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>My Poems</title> <style> p:hover { color: red; font-weight: bold; } body { background-color: MistyRose; font-family: Arial, sans-serif; color: DarkSlateGray; } h2 { font-size: 30px; font-family: Georgia, serif; color: DarkSlateBlue; margin-bottom: 5px; } p { font-size: 20px; line-height: 28px; margin-top: 0px; margin-bottom: 20px; } .hover { color: white; background-color: DarkSlateGray; cursor: pointer; } </style> </head> <body> <h2>Poem 1</h2> <p>Roses are red,<br> Violets are blue,<br> Sugar is sweet,<br> And so are you.</p> <h2>Poem 2</h2> <p>There is a charm about<br> the forbidden that makes<br> it unspeakably desirable.</p> <script> var hoverEls = document.querySelectorAll('.hover'); hoverEls.forEach(function(hoverEl) { hoverEl.addEventListener('mouseover', function() { hoverEl.classList.add('hover'); }); hoverEl.addEventListener('mouseout', function() { hoverEl.classList.remove('hover'); }); }); </script> </body> </html>优化这段代码,为其段落给予不同的字体以及加入表格
对于代码的优化,可以像下面这样对段落进行样式调整,给予不同的字体,并且加入表格:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Poems</title>
<style>
body {
background-color: MistyRose;
font-family: sans-serif;
color: DarkSlateGray;
}
h2 {
font-size: 30px;
font-family: Georgia, serif;
color: DarkSlateBlue;
margin-bottom: 5px;
}
p:first-of-type {
font-size: 25px;
line-height: 35px;
font-family: Arial, sans-serif;
margin-top: 0px;
margin-bottom: 20px;
}
p:last-of-type {
font-size: 23px;
line-height: 33px;
font-family: Verdana, sans-serif;
margin-top: 20px;
margin-bottom: 0px;
}
table {
border-collapse: collapse;
border-spacing: 0px;
}
td {
padding: 10px;
border: 1px solid black;
}
</style>
</head>
<body>
<h2>Poem 1</h2>
<p>Roses are red,<br>
Violets are blue,<br>
Sugar is sweet,<br>
And so are you.</p>
<h2>Poem 2</h2>
<p>There is a charm about<br>
the forbidden that makes<br>
it unspeakably desirable.</p>
<table>
<tr>
<td>表格中的内容1</td>
<td>表格中的内容2</td>
</tr>
<tr>
<td>表格中的内容3</td>
<td>表格中的内容4</td>
</tr>
</table>
</body>
</html>