//grid 1 details
const arrayOfReactUrls =
'{"https://create-react-app.dev/docs/getting-started":"React Start",\
"https://scrimba.com/learn/learnreact/first-react-coc0845dcb1a26cb0769a2fea":"React training",\
"https://www.digitalocean.com/community/tutorials":"Digital Ocean Tutorials",\
"https://www.joshwcomeau.com/react/common-beginner-mistakes/":"React Beginner mistakes"\
}';
let obj = JSON.parse(arrayOfReactUrls);
for (let key in obj) {
elem = document.createElement('div');
elem.setAttribute('id', obj[key]);
elem.innerHTML = `<a href=${key}>${obj[key]}</a>`;
document.querySelector('.my_grid_react').append(elem);
}
//grid 2 details
const arrayOfPythonUrls =
'{"https://docs.python.org/3/library/stdtypes.html#dict":"Python dictionary",\
"https://docs.python.org/3/library/stdtypes.html#typesseq-common":"Python Sequence",\
"https://docs.python.org/3/reference/expressions.html#comparisons":"Python expressions",\
"https://pythontutor.com/visualize.html#mode=edit":"Python visualiser",\
"https://towardsdatascience.com/unpacking-operators-in-python-306ae44cd480":"Unpacking operator"\
}';
obj = JSON.parse(arrayOfPythonUrls);
for (let key in obj) {
elem = document.createElement('div');
elem.setAttribute('id', obj[key]);
elem.innerHTML = `<a href=${key}>${obj[key]}</a>`;
document.querySelector('.my_grid_python').append(elem);
}
.my_grid_react {
display: grid;
float: left;
grid-template-columns: repeat(1, auto);
background-color: lightgreen;
width: 50%;
}
.my_grid_react div {
background-color: yellow;
margin: 8px;
padding: 6px;
font-size: 14px;
}
.my_grid_python {
display: grid;
grid-template-columns: repeat(1, auto);
background-color: orange;
width: 50%;
}
.my_grid_python div {
background-color: aqua;
margin: 8px;
padding: 6px;
font-size: 14px;
}
<div class="my_grid_react"></div>
<div class="my_grid_python"></div>
我创建了2个grids
,并使用float
将2个网格相邻放置;现在我希望在网格(其背景颜色为lightgreen
)和网格(其背景颜色为orange
)之间有一个小的垂直白色间隙,比如5 px,请建议如何在相邻网格之间放置垂直间隙。
1条答案
按热度按时间oxcyiej71#
使用CSS flex(如果需要,也可以使用grid,actually a mix of the two)
gap
创建父Flex.row
.col
flex与gap
配合使用createMenu()
的函数,它接受选择器目标和JSONArray
,这显然不是数组。(这是一个JSON字符串)grid