这是我的网站:sanyigarazs.atw.hu
在“ Kapcsolat”页面上,有一个文本区域。
在Google Chrome浏览器中,它会调整为合适的大小,但是在某些浏览器(Edge,Mozilla)中,页面的其他元素比文本区域宽,这很烦人。
这是我的标记:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Kapcsolat</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Quicksand">
<link rel="stylesheet" type="text/css" href="mainn.css">
<body>
<div class="container">
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a href="index.html" class="navbar-brand">Sanyigarázs</a>
</div>
<div class="nav navbar-nav">
<li><a href="rolunk.html">Rólunk</a></li>
<li><a href="#">Kapcsolat</a></li>
<li><a href="weboldalrol.html">Weboldalról</a></li>
</div>
<!-- <form class="form-inline">
<input class="form-control mr-sm-2" type="search" placeholder="Ide írja keresését." aria-label="Keresés">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Keresés</button>
</form> -->
</div>
</nav>
<div>
<h3 align="center">Hívjanak telefonon: 06999999999</h3>
<hr>
<h5 align="center">Vagy üzenjenek e-mailen keresztül:</h5>
<form id="uzenetes" action="emailtest.php" method="post">
<table border="0">
<tr>
<td align="center"><input type="text" placeholder="Az ön neve" name="username"
size="20" maxlength="150" width="150"/></td>
</tr>
<tr>
<td align="center"><input placeholder="Az ön e-mail címe" type="text" name="address"
size="20" maxlength="150" width="150"/></td>
</tr>
<tr>
<td align="center"><input type="text" placeholder="Az üzenet tárgya" name="subject"
size="20" maxlength="150"/></td>
</tr>
<tr>
<td><textarea id="message" name="message" placeholder="Ide írja üzenetét..." size="20" maxlength="150"></textarea></td>
</tr>
<td colspan="2" align="center"><input id="button" type="submit"
value="Elküldés"/></td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>
form {
margin: 0 auto;
width:240px;
font-size: 150%;
}
td {
display: block;
padding: 5px;
}
textarea {
width: 230px;
margin-top: 0%;
resize: vertical;
}
#mobile {
padding: 30px;
}
body {
font-family: 'Quicksand', sans-serif;
}
.thumbnail {
transition: all 0.2s;
}
.thumbnail:hover {
transform: scale(1.1);
}
p {
text-align: center;
}
.jumbotron {
border: 1px solid black;
}
.tested {
font-size: 140%;
}
.bug {
padding: 15px;
border-top: 1px solid black;
}
.navbar-inverse {
transition: all 0.2s;
}
.navbar-inverse:hover {
transform: scale(1.03);
}
.weboldalroltext {
padding-bottom: 3px;
}
body {
padding-top: 70px;
}
.mainHeader {
padding-bottom: 50px;
}
.navbar {
padding-top: 5px;
font-size: 20px;
}
.navbar-brand {
font-size: 20px;
}
a:after {
display: block;
content: '';
border-bottom: solid 3px #fff;
transform: scaleX(0);
transition: transform 250ms ease-in-out;
padding: 5px 0px 0px 0px;
}
a:hover:after {
transform: scaleX(1);
}
.helloka {
width: 300px;
font-size: 25px;
}
hr {
height: 10px;
border: 0;
box-shadow: inset 0 12px 12px -12px rgba(0, 0, 0, 0.5);
}
form {
padding-top: 10px;
}
h5 {
font-size: 18px;
}
所以我想使textarea的大小等于其他元素(230像素),但是它仅在chrome浏览器中有效。
谢谢您的帮助,克里斯托夫。
答案 0 :(得分:0)
首先,编辑您的HTML代码。
在您的HTML中删除textarea
元素的size
属性和input
元素的width
属性,因为它们无效。而且,您无需为size=20
使用input
,因为这是默认设置。
然后,像这样更改您的CSS:
input[type="text"],
textarea {
width: 230px /* or you can use 100% */
/* P.S. The resize option is not supported by Edge */
}
form {
margin: 0 auto;
width:240px;
font-size: 150%;
}
td {
display: block;
padding: 5px;
}
input[type="text"],
textarea {
width: 230px
}
textarea {
margin-top: 0%;
resize: vertical;
}
#mobile {
padding: 30px;
}
body {
font-family: 'Quicksand', sans-serif;
}
.thumbnail {
transition: all 0.2s;
}
.thumbnail:hover {
transform: scale(1.1);
}
p {
text-align: center;
}
.jumbotron {
border: 1px solid black;
}
.tested {
font-size: 140%;
}
.bug {
padding: 15px;
border-top: 1px solid black;
}
.navbar-inverse {
transition: all 0.2s;
}
.navbar-inverse:hover {
transform: scale(1.03);
}
.weboldalroltext {
padding-bottom: 3px;
}
body {
padding-top: 70px;
}
.mainHeader {
padding-bottom: 50px;
}
.navbar {
padding-top: 5px;
font-size: 20px;
}
.navbar-brand {
font-size: 20px;
}
a:after {
display: block;
content: '';
border-bottom: solid 3px #fff;
transform: scaleX(0);
transition: transform 250ms ease-in-out;
padding: 5px 0px 0px 0px;
}
a:hover:after {
transform: scaleX(1);
}
.helloka {
width: 300px;
font-size: 25px;
}
hr {
height: 10px;
border: 0;
box-shadow: inset 0 12px 12px -12px rgba(0, 0, 0, 0.5);
}
form {
padding-top: 10px;
}
h5 {
font-size: 18px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Kapcsolat</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Quicksand">
<link rel="stylesheet" type="text/css" href="mainn.css">
<body>
<div class="container">
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a href="index.html" class="navbar-brand">Sanyigarázs</a>
</div>
<div class="nav navbar-nav">
<li><a href="rolunk.html">Rólunk</a></li>
<li><a href="#">Kapcsolat</a></li>
<li><a href="weboldalrol.html">Weboldalról</a></li>
</div>
<!-- <form class="form-inline">
<input class="form-control mr-sm-2" type="search" placeholder="Ide írja keresését." aria-label="Keresés">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Keresés</button>
</form> -->
</div>
</nav>
<div>
<h3 align="center">Hívjanak telefonon: 06999999999</h3>
<hr>
<h5 align="center">Vagy üzenjenek e-mailen keresztül:</h5>
<form id="uzenetes" action="emailtest.php" method="post">
<table border="0">
<tr>
<td align="center"><input type="text" placeholder="Az ön neve" name="username" maxlength="150"></td>
</tr>
<tr>
<td align="center"><input placeholder="Az ön e-mail címe" type="text" name="address" maxlength="150"></td>
</tr>
<tr>
<td align="center"><input type="text" placeholder="Az üzenet tárgya" name="subject" maxlength="150"></td>
</tr>
<tr>
<td><textarea id="message" name="message" placeholder="Ide írja üzenetét..." maxlength="150"></textarea></td>
</tr>
<td colspan="2" align="center"><input id="button" type="submit"
value="Elküldés"/></td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>
答案 1 :(得分:-1)
每个浏览器都有自己的预定义CSS样式表。要对其进行标准化,请使用“重置CSS”代码段。您可以在Google中找到一些代码。
将其放入reset.css文件中,并在包含mainn.css之前将其链接到头部。
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;
}