Yale Newman
Yale Newman

Reputation: 1231

Despite looking at several similar questions, I am still unable to style an Input element and Submit form the same

.nav {
	height: 60px;
	background-color: rgba(128, 128, 128, 0.24);
	background-size: cover;
	display: inline-block;
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	float: left;
	clear: right;
	font-family: 'Roboto', sans-serif;
}

.home{
	text;
	text-decoration: none;
	position: absolute;
	left: 20px;
	top: 15px;
	font-size: 1.5em;
	color:black;
}

.navList {
	display: inline-block;
	position: absolute;
	right: 30px;
}

.navLi {
	display: inline-block;
	padding-right: 5px;
	padding-left: 5px;
}

.navLi a {
	text-decoration:none;
	font-size: 1.5em;
}

.searchBox {
    margin-top: 90px;
    width: 1000px;
    margin-left: auto;
    margin-right: auto;
    height: 100px;
}

.searchSubmit {
	background: url("magnifying-glass.png");
	height: 30px;
	width: 30px;
	background-size: 100%;
}
<body>
	<div class="wrapper">
		<!-- ========= START OF NAVBAR ======= -->
		<div class="nav">
			<a href="" class="home">Greg's List</a>
			<ul class="navList" title="navigation">
				<li class="navLi"><a href="">Post</a></li>
				<li class="navLi"><a href="">Account</a></li>
			</ul>
		</div>
		<!-- ========= END OF NAVBAR ======= -->

		<!-- ========= Search Box Start======= -->
		<div class="searchBox">
			<label>Search Jobs</label>
			<div class="searchInputBox">
				<form>
					<input class="searchInput" type="search" placeholder="Search Software Jobs">
					<button class="searchSubmit" type="submit"></button>
				</form>
			</div>
		</div>
		<!-- ========= Search Box End======= -->
	</div>
</body>

There are several questions that are the exact same. This is one.

I have an image that is 30 pixels by 30 pixels. I am using this image as the background for a submit button. I need to increase the height of the input element so that it is the same height as the submit button, 30 pixels.

For some reason, I haven't been able to increase the height of the input element using the height property. I am using inline-block so that can't be it.

Desired Output

Upvotes: 0

Views: 46

Answers (3)

ankita patel
ankita patel

Reputation: 4251

Please try this. Give vertical-align:middle to input and button.

form input {
  vertical-align: middle;
  border:1px solid #ccc;
  height:40px;
  border-radius:5px;
  padding: 0 10px;
}
.searchSubmit {
  background: url("https://cdn4.iconfinder.com/data/icons/pictype-free-vector-icons/16/search-16.png") no-repeat 0 0; /*this image url is only for refrence*/
  background-position: center;
  height: 40px;
  width: 40px;  
  vertical-align:middle;
  border:1px solid #ccc;
  border-radius:5px;
}

.nav {
  height: 60px;
  background-color: rgba(128, 128, 128, 0.24);
  background-size: cover;
  display: inline-block;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  float: left;
  clear: right;
  font-family: 'Roboto', sans-serif;
}

.home{	
  text-decoration: none;
  position: absolute;
  left: 20px;
  top: 15px;
  font-size: 1.5em;
  color:black;
}

.navList {
  display: inline-block;
  position: absolute;
  right: 30px;
}

.navLi {
  display: inline-block;
  padding-right: 5px;
  padding-left: 5px;
}

.navLi a {
  text-decoration:none;
  font-size: 1.5em;
}

.searchBox {
  margin-top: 90px;
  width: 1000px;
  margin-left: auto;
  margin-right: auto;
  height: 100px;
}
form input {
  vertical-align: middle;
  border:1px solid #ccc;
  height:40px;
  border-radius:5px;
  padding: 0 10px;
}
.searchSubmit {
  background: url("https://cdn4.iconfinder.com/data/icons/pictype-free-vector-icons/16/search-16.png") no-repeat 0 0; /*this image url is only for refrence*/
  background-position: center;
  height: 40px;
  width: 40px;  
  vertical-align:middle;
  border:1px solid #ccc;
  border-radius:5px;
}
<body>
  <div class="wrapper">
    <!-- ========= START OF NAVBAR ======= -->
    <div class="nav">
      <a href="" class="home">Greg's List</a>
      <ul class="navList" title="navigation">
        <li class="navLi"><a href="">Post</a></li>
        <li class="navLi"><a href="">Account</a></li>
      </ul>
    </div>
    <!-- ========= END OF NAVBAR ======= -->

    <!-- ========= Search Box Start======= -->
    <div class="searchBox">
      <label>Search Jobs</label>
      <div class="searchInputBox">
        <form>
          <input class="searchInput" type="search" placeholder="Search Software Jobs">
          <button class="searchSubmit" type="submit"></button>
        </form>
      </div>
    </div>
    <!-- ========= Search Box End======= -->
  </div>
</body>

Upvotes: 0

nish
nish

Reputation: 1221

Please try this code. You can change the 'height' property of the button.

CSS

.nav {
height: 60px;
background-color: rgba(128, 128, 128, 0.24);
background-size: cover;
display: inline-block;
position: fixed;
top: 0;
left: 0;
width: 100%;
float: left;
clear: right;
font-family: 'Roboto', sans-serif;
}

.home{
text;
text-decoration: none;
position: absolute;
left: 20px;
top: 15px;
font-size: 1.5em;
color:black;
}

.navList {
display: inline-block;
position: absolute;
right: 30px;
}

.navLi {
display: inline-block;
padding-right: 5px;
padding-left: 5px;
}

.navLi a {
text-decoration:none;
font-size: 1.5em;
}

.searchBox {
margin-top: 90px;
width: 1000px;
margin-left: auto;
margin-right: auto;
height: 100px;
}

.searchSubmit {
background: url("magnifying-glass.png");
height: 20px;
width: 30px;
background-size: 100%;
}

HTML

 <body>
 <div class="wrapper">
    <!-- ========= START OF NAVBAR ======= -->
    <div class="nav">
        <a href="" class="home">Greg's List</a>
        <ul class="navList" title="navigation">
            <li class="navLi"><a href="">Post</a></li>
            <li class="navLi"><a href="">Account</a></li>
        </ul>
    </div>
    <!-- ========= END OF NAVBAR ======= -->

    <!-- ========= Search Box Start======= -->
    <div class="searchBox">
        <label>Search Jobs</label>
        <div class="searchInputBox">
            <form>
                <input class="searchInput" type="search" 
                  placeholder="Search Software Jobs">
                <button class="searchSubmit" type="submit"></button>
            </form>
        </div>
    </div>
    <!-- ========= Search Box End======= -->
  </div>
  </body>

Upvotes: 2

Vincent1989
Vincent1989

Reputation: 1657

Why not? There are few default browser CSS you need to overwrite to achieve this.

Try the css below:

input.searchInput {
    padding: 0;
    margin: 0;
    height: 100%;
    display: inline-block;
    vertical-align: middle;
}

button.searchSubmit {
    padding: 0;
    margin: 0;
    border: 1px solid grey;
    height: 100%;
    display: inline-block;
    vertical-align: middle;
}

form {
    height: 30px;
}

Example:

.nav {
	height: 60px;
	background-color: rgba(128, 128, 128, 0.24);
	background-size: cover;
	display: inline-block;
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	float: left;
	clear: right;
	font-family: 'Roboto', sans-serif;
}

.home{
	text;
	text-decoration: none;
	position: absolute;
	left: 20px;
	top: 15px;
	font-size: 1.5em;
	color:black;
}

.navList {
	display: inline-block;
	position: absolute;
	right: 30px;
}

.navLi {
	display: inline-block;
	padding-right: 5px;
	padding-left: 5px;
}

.navLi a {
	text-decoration:none;
	font-size: 1.5em;
}

.searchBox {
    margin-top: 90px;
    width: 1000px;
    margin-left: auto;
    margin-right: auto;
    height: 100px;
}

.searchSubmit {
	background: url("magnifying-glass.png");
	height: 30px;
	width: 30px;
	background-size: 100%;
}

input.searchInput {
    padding: 0;
    margin: 0;
    height: 100%;
    display: inline-block;
    vertical-align: middle;
}

button.searchSubmit {
    padding: 0;
    margin: 0;
    border: 1px solid grey;
    height: 100%;
    display: inline-block;
    vertical-align: middle;
}

form {
    height: 30px;
}
<body>
	<div class="wrapper">
		<!-- ========= START OF NAVBAR ======= -->
		<div class="nav">
			<a href="" class="home">Greg's List</a>
			<ul class="navList" title="navigation">
				<li class="navLi"><a href="">Post</a></li>
				<li class="navLi"><a href="">Account</a></li>
			</ul>
		</div>
		<!-- ========= END OF NAVBAR ======= -->

		<!-- ========= Search Box Start======= -->
		<div class="searchBox">
			<label>Search Jobs</label>
			<div class="searchInputBox">
				<form>
					<input class="searchInput" type="search" placeholder="Search Software Jobs">
					<button class="searchSubmit" type="submit"></button>
				</form>
			</div>
		</div>
		<!-- ========= Search Box End======= -->
	</div>
</body>

Upvotes: 0

Related Questions