如何在它们下面制作两列和输入框?像这样:

时间:2018-11-30 12:19:23

标签: javascript html css

我的代码有问题。我无法设计要在此处上传的人。我不能在两栏及其下方输入框,当按下按钮时将显示它们。 我想成为的设计:enter image description here 这是我的代码HTML:

<!DOCTYPE html>
    <html>
    <head>
    	<!--<link rel="stylesheet" type="text/css" href="raboti.css">-->
    	<h1>Calculator</h1>
    	
    	<!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">-->
    	<link rel="stylesheet" type="text/css" href="withbootstat.css">
    </head>
    <body>
    	
    	<div class="row">
    		<div class="dropDown" style="background-color: #efefef;">
    			<h2>Брой служители:</h2>
    				<select id="mySelect">
    					<option value="1">1-10</option>
    					<option value="2">11-30</option>
    					<option value="3">31-80</option>
    					<option value="4">81-150</option>
    					<option value="5">151-300</option>
    					<option value="6">300+</option>
    				</select>
    			 
    		</div>
    
    		<div class="dropDown" id="monthCost" style="background-color: #efefef;">
    			<h2>Месечен разход(лв.):</h2> <input type="text" id="ourSum">
    		</div>
    	</div>
    
    	<div class="row1">
    		<div class="sum" id="finalSum">
    			При нас цената ще е: <input class="hide type="text" id="result" >
    			<br><button type="button" onclick="sum()">Изчисли</button>
    
    		</div>
    	</div>
    
    </body>
    </html>
这是我从w3school获得的两列代码。 这是我的CSS代码:

* {
        box-sizing: border-box;
    }
    .dropDown {
        float: left;
        width: 50%;
        padding: 10px;
        height: 300px; /* Should be removed. Only for demonstration */

    }
    .row:after {
        content: "";
        display: table;
        clear: both;
    }
    @media screen and (max-width:600px) {
        .dropDown {
            width: 100%;
        }
    }
    h1 {
        text-align: center;
    }
    .row1 {
        margin-top: -200px;
        margin-left: 100px;
    }
    .hide{
      display:none;
    }
    .show{
      display:block;
    }

1 个答案:

答案 0 :(得分:0)

根据您的照片,您可以使用flexbox来实现自己的目标:

.flex-center {
  justify-content: center;
  align-items: center;
}

.flex-column {
  flex-direction: column;
}

.flex-justify-around {
  justify-content: space-around;
}

.w-100 {
  width: 100%;
}

.mr-50 {
  margin-right: 50px;
}

.ml-50 {
  margin-left: 50px;
}

.round-box {
  border: 2px solid #ccc;
  border-radius: 150px;
  padding: 20px;
}

.d-flex {
  display: flex;
}

.grow {
  flex: 1 0 0;
}

.flex-wrap {
  flex-wrap: wrap;
}

.p-40 {
  padding: 40px;
}

.pt-0 {
  padding-top: 0 !important;
}

.pr-40 {
  padding-right: 40px;
}

.pl-40 {
  padding-left: 40px;
}

.bg-blue {
  background-color: #00B6FD;
  color: white;
}

.text-blue {
  color: #00348C;
}

.font-weight-bold {
  font-weight: bold;
}
<div class="d-flex flex-center flex-column flex-wrap text-blue">
  <div class="d-flex flex-center flex-column">
    <h1>Calculator</h1>
  </div>
  <div class="d-flex flex-center flex-justify-around w-100 flex-wrap">
    <div class="d-flex flex-column grow p-40 pt-0">
      <h4>Question</h4>
      <input type="text" class="round-box " id="bx-1"/>
    </div>
    <div class="d-flex flex-column grow p-40 pt-0">
      <h4>Answer</h4>
      <input type="text" class="round-box" id="bx-1"/>
    </div>
  </div>
  <input type="button" value="Submit" class="round-box pl-40 pr-40 bg-blue font-weight-bold"/>
</div>

另外,这是working example:)

顺便提一句,这个也应该有响应;)