gpt4 book ai didi

Html - 减少水平线和图像之间的间距

转载 作者:行者123 更新时间:2023-11-28 11:07:52 26 4
gpt4 key购买 nike

我正在开发一个基于 HTML 的用户界面,因为我是 css 的新手,所以请提出建议。
我想格式化我的 UI,以便顶部和底部线与按钮之间的间距减小。
还要将文本向上移动一点,使其位于与按钮对齐的中心。

请看附件图片,我已经对其进行了编辑并添加了箭头。

是否可以用一些单个 TAB 替换多个  

<!DOCTYPE html>
<html>
<head>
<style>
body
{
background-color:#292B3B;
}
h1 {color:white;}
p {color:#DDDFED; font-size:150%; text-indent:5px; align="middle"}

</style>
</head>

<body>

<h1>My CSS web page!</h1>
<hr>

<p>
<input type="image" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS6QBsJ91Xp2YoqjiDe4qbYAGSf8deoyI0c1TutLDPrxwuQb34-" onclick="alert('clicked')" value="Submit" alt="Bulb pop up" width="48" height="48" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
Button One

</p>

<hr>


<p>
<input type="image" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS6QBsJ91Xp2YoqjiDe4qbYAGSf8deoyI0c1TutLDPrxwuQb34-" onclick="alert('clicked')" value="Submit" alt="Bulb pop up" width="48" height="48" />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
Button Two

</p>

<hr>


</body>
</html>

enter image description here

最佳答案

问题是您没有重置浏览器应用的默认 marginpadding,因此请使用下面的代码片段。

* {
margin: 0;
padding: 0;
}

Demo

或者要获得最大程度的跨浏览器体验,您可以使用 CSS Reset Stylesheet .

您将需要下面的代码片段来将您的图像垂直居中对齐..

input[type=image] {
vertical-align: middle;
}

此外,align="middle" 不正确,您应该改用 text-align: center;


四舍五入……

Final Demo

* {
margin: 0;
padding: 0;
}

body {
background-color:#292B3B;
}

h1 {
color:white;
padding: 10px;
}

p {
color:#DDDFED;
font-size:150%;
text-indent:5px;
padding: 10px;
}

input[type=image] {
vertical-align: middle;
}

关于Html - 减少水平线和图像之间的间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22165251/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com