Im sure it is a very simple fix that i just can't see. I want the second button on the left hand side to be below the one on the right hand side in terms of height on the page but still on the left hand side. I have included a JS fiddle
https://jsfiddle.net/fraserdale/knpvwhad/
Thanks for your help in advanced
<div >
<p>
<select id="shipping" style="float: right;">
<option value="-40">UK / AUS $40 </option>
<option value="-13.95">US $13.95</option>
<option value="-30">CAN $30</option>
<option value="0">Free</option>
</select>
Shipping:
</p>
</div>
<button class="button" onclick="myFunction()">Submit</button>
and the CSS
.button {
background-color: #41ad33;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px 4px 0px;
cursor: pointer;
}
select{
padding: 15px 9.25px ;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px 4px 0px;
cursor: pointer;
Set the button to be a block level element and then use clear property:
.button {
background-color: #41ad33;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
font-size: 16px;
margin: 4px 2px 4px 0px;
cursor: pointer;
display: block;
clear: right;
}
select {
padding: 15px 9.25px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px 4px 0px;
cursor: pointer;
}
p {
font-weight: bold;
}
<div>
<p>
<select id="shipping" style="float: right;">
<option value="-40">UK / AUS $40 </option>
<option value="-13.95">US $13.95</option>
<option value="-30">CAN $30</option>
<option value="0">Free</option>
</select> Shipping:
</p>
</div>
<button class="button" onclick="myFunction()">Submit</button>
Instead of using a float, I would suggest using a flexbox container. Using the property justify-content: space-between; you can make sure that your select is aligned all the way to the right. Another benefit is that you can vertically align items in a flexbox with align-items: center;, which will remove the need to further position the label aswel.
For more info on flexbox, see: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
.button {
background-color: #41ad33;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px 4px 0px;
cursor: pointer;
clear:both;
}
select{
padding: 15px 9.25px ;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px 4px 0px;
cursor: pointer;
}
label {
font-weight: bold;
}
.input-container {
display:flex;
justify-content:space-between;
align-items: center;
}
<div class="input-container">
<label for="shipping">
Shipping:
</label>
<select id="shipping">
<option value="-40">UK / AUS $40 </option>
<option value="-13.95">US $13.95</option>
<option value="-30">CAN $30</option>
<option value="0">Free</option>
</select>
</div>
<button class="button" onclick="myFunction()">Submit</button>
Add a new element with the clear:both property to put the floating element below your right button like this
https://jsfiddle.net/RACCH/13rt8eom/
<div >
<p>
<select id="shipping" style="float: right;">
<option value="-40">UK / AUS $40 </option>
<option value="-13.95">US $13.95</option>
<option value="-30">CAN $30</option>
<option value="0">Free</option>
</select>
Shipping:
</p>
<div class="clear"></div>
<button class="button" onclick="myFunction()">Submit</button>
</div>
Related
I have an image contained inside a element. I scaled the image to 25% using css. Now, however, the element width didn't change. Help would be appreciated. I want the elemnent's width, to match the width of the image. If this isn't possible with css, I can just use JavaScript. Thanks
html
form {
padding-left: 10px
}
h1 {
font-size: 50px;
text-align: center
}
.center {
text-align: center;
margin-left: auto;
margin-right: auto;
}
body {
background-color: #CDCDCD
}
.imageContain {
display: inline-block;
}
th {
border: 1px solid #000000;
display: inline-block
}
<h1>Data Calculator (Mean, Median, Mode, Range, and Average)</h1>
<table align="center">
<th>
<div>
<label>Put numbers here. Separated by a space</label><br>
<input id="input" />
<br>
<select id="selection">
<option value="mean">Mean</option>
<option value="median">Median</option>
<option value="mode">Mode</option>
<option value="range">Range</option>
<option value="average">Average</option>
</select>
<br>
<br>
<button id="output" onclick="submit()">Output</button><br>
<label id="result"><label>
</div>
</th>
<th>
<img src="https://i.imgur.com/dHhcc5a_d.webp?maxwidth=760&fidelity=grand" style="max-width:25%">
</th>
</table>
body {
background-color: #CDCDCD
}form {
padding-left: 10px
}
h1 {
font-size: 50px;
text-align: center
}
th {
border: 1px solid #000000;
display: inline-block
}
.center {
text-align: center;
margin-left: auto;
margin-right: auto;
}
.box{
width: 20rem;
height: 22rem;
}
label{
font-size: 27px;
font-weight: bold;
padding-top: 30px!important;
}
input{
margin-top: 80px;
font-size: 18px;
padding: 5px 10px ;
outline: none;
border: 1px solid black;
}
select{
margin-top: 20px;
font-size: 18px;
padding: 5px 10px;
outline: none;
border: 1px solid black;
}
button{
font-size: 18px;
padding: 5px 10px;
outline: none;
border: 1px solid black;
}
.img-th{
border: none;
}
th img{
width: 50%;
height: 50%;
border-radius: 50px;
border:none;
}
<h1>Data Calculator (Mean, Median, Mode, Range, and Average)</h1>
<table align="center">
<th>
<div class="box">
<label>Put numbers here. Separated by a space</label><br>
<input id="input" />
<br>
<select id="selection">
<option value="mean">Mean</option>
<option value="median">Median</option>
<option value="mode">Mode</option>
<option value="range">Range</option>
<option value="average">Average</option>
</select>
<br>
<br>
<button id="output" onclick="submit()">Output</button><br>
<label id="result"><label>
</div>
</th>
<th class="img-th"><img src="https://i.imgur.com/dHhcc5a_d.webp?maxwidth=760&fidelity=grand"></th>
</table>
Is this your answer?
I'm trying to fix an issue with a hoverable span in html. Inside the span element is a html-select option. When I try to select something, the hoverable span disappears.
This issue only occurs in Firefox. In Chrome I don't have this issue.
HTML Part:
<span class="over">
<i class="fa fa-cogs edit"></i>
<div>
<form method="post" accept-charset="utf-8" action="/edit">
<div class="input select">
<label for="select-id">Select</label>
<select name="select_id" id="select-id">
<option value="">-- select --</option>
<option value="1">A</option>
<option value="2">B</option>
<option value="3">C</option>
</select>
</div>
</form>
</div>
</span>
SCSS Part:
.over{
margin-right: 0.5em;
&>i{
color: #bbbbbb;
padding: 2px;
}
&>a{
padding: 2px;
display: none;
&:hover{
color: #000;
}
}
&>div{
display: none;
position: absolute;
border: 1px solid #ccc;
margin: 6px 0 0 -20px;
padding: 2px;
background: white;
border-radius: 4px;
min-width: 140px;
z-index: 100;
text-align: left;
input, select{
padding: 0 5px;
line-height: 1.5em;
width: auto;
display: inline-block;
}
label{
margin: -4px 4px;
display: inline-block;
}
}
&:hover{
border: 1px solid;
border-radius: 4px;
&>i{
color: #000;
}
&>a{
display: inherit;
}
&>div{
display: inline-block;
}
}
}
}
In Chrome I can hover over the span item and select a option from the select-element. Even if I leave the hoverable area.
In Firefox I can also hover over the div, but as soon as I leave the hoverable area, the box disappears and I cannot select an Item.
Problem seems to be fixed in Firefox now.
I am a CSS newbie, maybe you laugh about my problem...
I have 2 main DIVs ("topinfo" and "navigat"), and I need them to stay separated, one after other, but for some reason they don't.
Running code on Fiddle: https://jsfiddle.net/7mgfrhq6/
Here is the HTML code:
<div id="topinfo">
<div id="infowin">
<div id="computer">
<b>Computer:</b> 123456789012345 (192.168.560.000)
<img src="http://i.imgur.com/Y1CJmSa.png" id="more"/>
</div>
</div>
<div id="statbtn">
<a href="stats.htm" target="_blank">
<img src="http://i.imgur.com/rh4XEOQ.png" id="bstats">
</a>
</div>
</div>
<div class="navigat">
« First
« Prior
<select class="navsel" onchange="self.location.href=options[selectedIndex].value">
<option selected="selected">Page 001</option>
<option value="pag002.htm">Page 002</option>
<option value="pag003.htm">Page 003</option>
<option value="pag004.htm">Page 004</option>
<option value="pag005.htm">Page 005</option>
</select>
Next »
Last »
</div>
Here is the CSS code:
#topinfo {
width: 420px;
margin: 16px auto 4px auto;
}
#topinfo #infowin {
float: left;
width: 380px;
border: 1px dotted #292929;
border-radius: 4px;
background-color: #FFFFE8;
}
#topinfo #infowin #computer {
padding: 6px;
font-family: Verdana, Tahoma, Helvetica;
font-size: 10pt;
text-align: center;
}
#topinfo #statbtn {
float: right;
width:32px;
height:32px;
border: 0;
}
.navigat {
width: 600px;
margin: 18px auto 14px auto;
font-family: Tahoma, Verdana, Helvetica;
text-align: center;
}
.navigat a.navbtn {
display: inline-block;
width:70px;
padding: 3px 3px 4px 3px;
margin: 3px;
font-size: 9pt;
color: #FFFFFF;
text-align: center;
text-decoration: none;
background-color: #1D63C8;
border-radius: 10px;
cursor: pointer;
}
.navigat select.navsel {
display: inline-block;
width:100px;
padding:3px;
margin: 3px;
font-size: 9pt;
line-height: 1;
cursor: pointer;
}
Here is what I got:
And here is what I really need:
Thanks for any help!
You need to clear the floats above when you get to .navigat and then add a bit of padding to get the desired spacing.
.navigat {
clear: both;
padding-top: 18px;
}
Recommended reading: Chris Coyier, All About Floats
This happens because of your float, you can solve this by adding an empty div in between "topinfo" and "navigat" with clear:both
HTML:
<div id="topinfo">
<div id="infowin">
<div id="computer">
<b>Computer:</b> 123456789012345 (192.168.560.000)
<img src="http://i.imgur.com/Y1CJmSa.png" id="more"/>
</div>
</div>
<div id="statbtn">
<a href="stats.htm" target="_blank">
<img src="http://i.imgur.com/rh4XEOQ.png" id="bstats">
</a>
</div>
</div>
<div class="clear"></div>
<div class="navigat">
« First
« Prior
<select class="navsel" onchange="self.location.href=options[selectedIndex].value">
<option selected="selected">Page 001</option>
<option value="pag002.htm">Page 002</option>
<option value="pag003.htm">Page 003</option>
<option value="pag004.htm">Page 004</option>
<option value="pag005.htm">Page 005</option>
</select>
Next »
Last »
</div>
CSS:
.clear
{
clear:both;
}
DEMO
This is happending because of the floats that you are using to align the div of #topinfo.
What you can do is make the inside as display:inline-block. So this will be something like this..
#topinfo #infowin {
display:inline-block
width: 380px;
border: 1px dotted #292929;
border-radius: 4px;
background-color: #FFFFE8;
}
#topinfo #statbtn {
display:inline-block;
width:32px;
height:32px;
border: 0;
vertical-align: bottom;
}
If you want to use floats you can use clear:both on .navigat class.
I have a href button that I styled to have a blue padded border.
Here is how it looks.
It is stacking behind the header and the search bar and I cant figure out why.
If anyone can help me out. here is the html code of the 3 divs.
<div id="topnav">
<span>Home » Tutorials » How to show an example</span>
</div>
<div id="main">
<div id="buttons">
<a class="btn" href="">Recent</a>
</div>
<div class="form-main">
<form class="form-wrapper">
<input type="text" id="search" placeholder="Search for tutorials ...">
<select>
<option value="7" selected="selected">All</option>
<option value="1">Newbie</option>
<option value="2">Beginner</option>
<option value="3">Novice</option>
<option value="4">Educated</option>
<option value="5">Expert</option>
<option value="6">Professional</option>
</select>
<input type="submit" value="Search" id="submit">
</form>
</div>
</div>
</div>
Here is the css code:
#topnav {
background-color: #f2f2f2;
border-radius: 5px 5px 0 0;
display: block;
height: 30px;
line-height: 25px;
padding: 5px;
}
#main {
padding: 5px 15px;
}
#buttons {
text-align: center;
}
.form-main {
background-color: #f6f6f6;
border-color: #dedede #bababa #aaa;
border-radius: 3px;
padding: 8px;
}
.btn {
background: none repeat scroll 0 0 #2972a3;
border-radius: 5px;
color: #ffffff;
font-family: Arial;
font-size: 17px;
padding: 10px 20px;
text-decoration: none;
}
You is positioned after the size of its parent, #buttons, which get its height based of the height of your content, which is 20px, but the real height of your is 40px, which means 10px, both top and bottom, will be outside #buttons div.
Try adding display: inline-block to your button class (.btn) to make the parent get the size including the padding.
Check it out here: http://jsfiddle.net/yc31unad/
add display:inline-block; to your button style
.btn {
background: none repeat scroll 0 0 #2972a3;
border-radius: 5px;
color: #ffffff;
font-family: Arial;
font-size: 17px;
padding: 10px 20px;
text-decoration: none;
display: inline-block;
}
I'm admitting right at the start: this is my first attempt at HTML/CSS coding. So please excuse my code's messiness.
I have two problems: 1. When I shrink my browser window small enough to see a scroll bar, my three drop down menus disappear. 2. I am trying to center my button (Find Resources), but can't figure it out. I've tried auto-ing my left and right margins, I tried text aligning, but it messed up the placement of my three boxes (which have a width of 200px).
Thanks for any help someone can offer!
HTML:
<div id="resource-wrapper">
<div id="content">
<p class="resource-p">Welcome to Our Resource Center.</p>
<p class="resource-p">How may we help you?</p>
</div>
<div id=buttons-div>
<div id=select>
<select class="dropdown" name="field_related_brands_nid">
<option value="All" selected="selected">Any</option>
<option value="2511">Sample</option>
</select>
<select class="dropdown-2" name="field_related_technology_nid">
<option value="All" selected="selected">Any</option>
<option value="444">Sample</option>
</select>
<select class="dropdown-3" name="field_resource_type_value_many_to_one">
<option value="All" selected="selected">Any</option>
<option value="multimedia">Sample</option>
</select>
</div>
<div id=buttons>
<img src="Images/Buttons1.jpg" class="resource-image">
<img src="Images/Buttons2.jpg" class="resource-image">
<img src="Images/buttons3.jpg" class="resource-image">
</div>
<button type="submit" class="resource-p1">Find Resources</button>
</div>
</div>
CSS:
#resource-wrapper {
width: 850px;
margin: 0 auto;}
#content {
background-color: #669bcf;
padding: 1px;
width: 100%;}
.resource-p {
text-align: center;
font-size: 30px;
font-family: sans-serif;
color: white;
line-height: 15px}
#buttons-div {
position: relative;
width: 850px;}
#select {
position: fixed;
margin-top: 214px;
width: 850px;}
.dropdown {
width: 160px;
margin-left: 78px;}
.dropdown-2 {
width: 125px;
margin-left: 115px;}
.dropdown-3 {
width: 95px;
margin-left: 148px;}
.resource-image {
margin: 50px 0 0 58px;}
.resource-p1 {
padding: 16px 18px 13px 18px;
margin: 20px;
text-align: center;
font-size: 21px;
font-family: sans-serif;
color: white;
font-weight: bold;
background-color: #669bcf;
border-style: solid;
border-width: 1px 1px 3px 1px;
border-color: #d7e4f4;
border-radius: 5px;}
Your Dropdowns shouldn't stack as nothing is responsive in your site. If they have a set width like width: 800px; They should be fine. However make sure to have all your id's surrounded with a quote:
<div id=buttons-div>
should be
<div id="buttons-div">
To Center your Resource Button:
.resource-p1 {
margin: 12px auto;
text-align: center;
font-size: 21px;
font-family: sans-serif;
color: white;
font-weight: bold;
background-color: #669bcf;
border-style: solid;
border-width: 1px 1px 3px 1px;
border-color: #d7e4f4;
border-radius: 5px;
display: block;
}
DEMO
1) Change #select's position from fixed to absolute
2) Wrap your button in a container and give that container text-align:center
HTML
<div id="find-resources-container">
<button type="submit" class="resource-p1">Find Resources</button>
</div>
CSS
#find-resources-container {
text-align:center
}