美食好物分享
body {
fontfamily: Arial, sansserif;
margin: 0;
padding: 20px;
}
h1 {
textalign: center;
marginbottom: 30px;
}
.sharesection {
padding: 40px;
backgroundcolor: f5f5f5;
border: 1px solid ddd;
marginbottom: 50px;
}
.recipetitle {
marginbottom: 20px;
}
.description {
textalign: justify;
lineheight: 1.5;
}
.item {
marginbottom: 20px;
cursor: pointer;
}
.button {
backgroundcolor: 007bff;
color: fff;
padding: 10px 20px;
border: none;
borderradius: 5px;
cursor: pointer;
transition: backgroundcolor 0.3s;
}
.button:hover {
backgroundcolor: 0056b3;
}
美食好物分享
// 假设我们有一个数据数组,包含美食和好物信息
const recipes = [
{
title: "巧克力蛋糕",
description: "简单易学,口感丝滑,甜而不腻。",
image: "https://example.com/chocolatecake.jpg",
link: "https://www.example.com/chocolatecakerecipe"
},
{
title: "手工面包",
description: "健康美味,面包机轻松制作,周末烘焙好选择。",
image: "https://example.com/bread.jpg",
link: "https://www.example.com/breadrecipe"
},
// 更多数据...
];
function loadRecipes() {
// 清空现有列表
document.getElementById("recipes").innerHTML = "";
// 随机选择几条数据
const selectedRecipes = recipes.slice(0, 3);
selectedRecipes.forEach(recipe => {
const item = document.createElement("div");
item.classList.add("item");
item.innerHTML = `
${recipe.title}
${recipe.description}
查看详情
`;
document.getElementById("recipes").appendChild(item);
});
}