标签<a> and tag <input/>

时间:2018-11-27 16:15:05

标签: html css web

I am using CSS reset you can find here : https://meyerweb.com/eric/tools/css/reset/

之间的CSS区别

这是HTML代码:

<input class="submitForm" type="submit" value="Confirm" />
<a class="cancelForm" href="{{ path('my_path') }}">Cancel</a>

这是CSS代码:

.submitForm {
    text-decoration: none;
    font-family: "Aero Matics", sans-serif;
    color: #FFFFFF;
    font-size: 20px;
    padding: 20px;
    background-color: #65BCF1;
    border: 0px none;
    font-weight:bold;
    float:right;
    cursor: pointer;
}

.cancelForm {
    text-decoration: none;
    font-family: "Aero Matics", sans-serif;
    color: #FFFFFF;
    font-size: 20px;
    padding: 20px;
    background-color: #ff9667;
    border: 0px none;
    font-weight:bold;
    float:left;
}

这里是问题:

https://imgur.com/6xC2onI

在图像上,您可以在“取消”按钮下看到空白行。

我的问题是:应该使用哪个CSS属性使“基于标签的按钮”的大小与“确认”按钮的大小完全相同? (我希望按钮从相同的高度开始,并完全填充到页面底部,而没有空白行。)

2 个答案:

答案 0 :(得分:1)

在我们没有明确添加line-height属性的情况下,您特别在这里缺少height属性。参见下面的代码片段,我还在顶部添加了重置CSS代码(已应用的内容)

/* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
	margin: 0;
	padding: 0;
	border: 0;
	font-size: 100%;
	font: inherit;
	vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
	display: block;
}
body {
	line-height: 1;
}
ol, ul {
	list-style: none;
}
blockquote, q {
	quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
	content: '';
	content: none;
}
table {
	border-collapse: collapse;
	border-spacing: 0;
}
.submitForm {
    text-decoration: none;
    font-family: "Aero Matics", sans-serif;
    color: #FFFFFF;
    font-size: 20px;
    padding: 20px;
    background-color: #65BCF1;
    border: 0px none;
    font-weight:bold;
    float:right;
    cursor: pointer;
}

.cancelForm {
    text-decoration: none;
    font-family: "Aero Matics", sans-serif;
    color: #FFFFFF;
    font-size: 20px;
    padding: 20px;
    background-color: #ff9667;
    border: 0px none;
    font-weight:bold;
    float:left;
}
.submitForm,
.cancelForm {
	line-height: 22px;
}
<input class="submitForm" type="submit" value="Confirm" />
<a class="cancelForm" href="{{ path('my_path') }}">Cancel</a>

答案 1 :(得分:0)

首先,您的大多数CSS是相同的,因此只需要编写一次即可。

第二:添加display: inline-block可使marginpadding正常工作。

第三,如@Paulie_D <buttons><a>标签(链接)所述,它们不是一回事。阅读他们建议的文章。

.submitForm,
.cancelForm {
  background-color: #65BCF1;
  border: 0px none;
  color: #FFFFFF;
  cursor: pointer;
  display: inline-block;
  font-family: "Aero Matics", sans-serif;
  font-size: 20px;
  font-weight:bold;
  margin: 0;
  padding: 20px;
  text-decoration: none;
}

.cancelForm {
    background-color: #ff9667;
}
<input class="submitForm" type="submit" value="Confirm" />
<a class="cancelForm" href="{{ path('my_path') }}">Cancel</a>