网页风格紊乱

时间:2015-10-24 10:42:22

标签: javascript html css

我一直在尝试使用这个html页面格式化安静很长一段时间。我希望在屏幕中央看到这些以漂亮的美丽方式。任何帮助表示赞赏。

http://jsfiddle.net/bce9LfLL/ 我的代码是 CSS

* {
    margin:0;
    padding:0;
    font-family: tahoma;
}
body {
    padding: 30px;
}
#fileid{
width:10%;
height:15%;
}
div {
    width: 400px;
    height: 25px;
    background-color: white;
    box-shadow: 1px 2px 3px #ededed;
    position:relative;
    border: 1px solid #d8d8d8;
}
input[type='file'] {
    width:400px;
    height:25px;
    opacity:0
}
#val {
    width: 400px;
    height:25px;
    position: absolute;
    top: 0;
    left: 0;
    font-size:13px;
    line-height: 25px;
    text-indent: 10px;
    pointer-events: none;
}
#button {
    cursor: pointer;
    display: block;
    width: 90px;
    background-color: purple;
    height:25px;
    color: white;
    position: absolute;
    right:0;
    top: 0;
    font-size: 11px;
    line-height:25px;
    text-align: center;
    -webkit-transition: 500ms all;
    -moz-transition: 500ms all;
    transition: 500ms all;
}

#button:hover {
    background-color: blue;
}


body {
    background-color: linen;
}

div{
    color: maroon;
    margin-left: 40px;
    font-size:100%;
} 
#sid{
    color: maroon;
    margin-left: 40px;
    font-size:100%;
}

HTML

<div align="center">
<b>Model</b><select id="sid">
<option >Average</option>
<option>Sum</option>
<option>Highest</option>
</select><br>
<div id="fileip">
    <input type='file'> <span id='val'></span>
 <span id='button'>Select File</span>
 </input>
 </div>
<input type="submit" value="run"><br><br>
<input type="submit" value="Display"><br>
</div>

和 的JavaScript

$('#button').click(function () {
    $("input[type='file']").trigger('click');
})

$("input[type='file']").change(function () {
    $('#val').text(this.value.replace(/C:\\fakepath\\/i, ''))
})

页面看起来应该是这样的 enter image description here

2 个答案:

答案 0 :(得分:0)

有两种方法可以让我的头顶中心。首先,修正宽度并设置边距:0 auto;在您希望居中的元素上。第二是放位置:相对; left:calc(50% - YOURELEMENTWIDTH);

答案 1 :(得分:0)

使用<label>标记。

<body>
    <label for="model">Model</label>
<select id="model">
  <option>Average</option>
  <option>Sum</option>
  <option>Highest</option>
  
</select>
</body>

相关问题