Button not working after putting float property - html

I have a media query where my two buttons will go on opposite sides of the screen, so clearly I had to use the float property on the buttons.
At first I just put a left float on one button but that didn't centered the two buttons, so I went ahead and put a right float on the other. After doing so, the buttons didn't work.
I made a fiddle, and everything is in there... could someone help me?
Basically, what I want is that the two buttons are side by side and centered in the media query.
#media screen and (min-width: 600px) and (max-width: 1199px){
#mainButtons{
display: inline;
button{
width: 45%;
}
}
#oneButton{
margin-right: 10px !important;
.random-button{
float: left;
}
}
#twoButton{
.picky-eater-btn{
float: right;
margin-top: 0;
}
}
}
Fiddle: here

At first glance, I notice that your CSS syntax is invalid. You cannot put element styles inside another element style definition.
for example, you have button defined inside of #mainButtons. That is invalid.

Is this basically the result you want?
Fiddle - Fiddle link!
HTML
<div id="mainButtons">
<button class="btn btn-hg btn-warning one-button">BUTTON 1</button>
<button class="btn btn-hg btn-danger two-button">BUTTON 2</button>
</div>
CSS
#mainButtons {
min-width: 200px;
max-width: 800px;
margin: 0 auto;
}
#mainButtons button {
width: 46%;
float: left;
margin: 0 2%;
}
.one-button {
color: #FFFFFF;
text-align: center;
border-radius: 10px;
height: 150px;
box-shadow: 0px 10px #FF841A;
}
.two-button {
font-family:'Lato', sans-serif;
height:150px;
box-shadow: 0px 10px #D70A00;
}
.btn:active {
-webkit-transform: translateY(5px);
-ms-transform: translateY(5px);
transform: translateY(5px);
}

There were a lot of issues with your code. I will try to explain all of them to you, but first, here is a working fiddle:
JSFiddle
1. You cannot have nested CSS elements:
This is invalid:
#buttons{
button{
width: 100%;
}
}
Instead, use concatenation:
#buttons button{
width: 100%;
}
2. Floating width:100% elements is essentially useless in your case
You were attempting to float #oneButton and #twoButton, which is correct, but as divs, which are block elements, they innately have 100% width, so setting the width of the buttons inside them to 45% will still make them appear on different lines.
#oneButton, #twoButton
{
width: 45%;
}
.one-button, .two-button
{
width: 100%
}
3. Apply margins to the parent divs, not the buttons
Since you want the floated divs to appear on the same line, you should apply all CSS affecting margin, width, padding, etc. to the parent, not the child.
Hopefully this works for you. Remember that clean CSS is good CSS and it makes it easier for us to help you.
Once again, here is the fiddle.

Related

Aligning last div elements

I've tried to align last div element / elements using text-align-last property but it didn't work. I have much divs in the center, but my page is different on each resolution so I can't control if elements will be perfectly and none of them will be in last line alone or so, that's why I want to align them to left.
Fiddle: http://jsfiddle.net/ecn8c0pt/
Picture of my site:
Adding the following CSS will work.
http://jsfiddle.net/ecn8c0pt/1/
#gallery h2{
margin: 0;
height: 80px; /*Added height for the Heading */
font-size: 1.1em;
font-weight: 300;
color: #33CCFF;
}
.project{
display: inline-block;
margin: 0 15px 40px;
width: 156px; //To show in jsfiddle i reduced the width.
text-align: left;
float: left; //MUST CHANGE: Once you align left it will automatically float to left. Also the number of count per row will depends on the window width and div width.
}
.project .thumbnail{
width: 156px;//To show in jsfiddle i reduced the width.
height: 144px;
border-radius: 3px;
}
try adding styles to your CSS like these:
float:left;
min-width: 200px;
max-width: 200px;
and try to fix the width for the wrapping div tag
for example:
.wrapper {
width:1000px;
}
see in example DEMO and try to predict the width now when you control it good luck!

DIV gets pulled down even overflow is hidden

I have a header, it has two parts, left - the big breadcrumb, right - control buttons. Problem - when breadcrumb gets too long, right part drops down, but i want to hide breadcrumbs, not all, but the part that covers buttons. Below is image with short breadcrumb
Currently parent div is
width: auto;
text-align: left;
margin-left: 61px;
Breadcrumb is
display: inline-block;
text-align: left;
width: auto;
max-width: 60%;
overflow: hidden;
white-space: nowrap;
And the right button part is
z-index: 99999;
float: right;
display: inline-block;
I don't know why right part gets pulled down, i want just hide breadcrumb, cannot resolve it in chrome dev tool either.
This is what i want,
Maybe there is a little trick out there, noticed many variations of css display, any ideas?
Crappy demo: http://jsfiddle.net/a796joeq/
I suggest this for the "right button part":
z-index: 99999;
position: absolute;
right: 0px;
top: 0px;
display: inline-block;
Try to follow the proper concept so that you can deliver quality output.
You can use float concept to achieve this. For a better understanding, you can use widths initially.
For parent div use: 100%; For child divs use: 50% , 50% (total can be max of 100%)
Here is a fiddle (http://jsfiddle.net/kiranvarthi/ybt5tc8b/3/) of the below:
.parent { width: 100%; background: green; overflow: hidden; }
.child1 { width: 30%; float: left; color: #fff; }
.child2 { width: 30%; float: left; color: #fff; }
HTML
<div class="parent">
<div class="child">
Child 1 content comes here.
</div>
<div class="child">
Child 2 content comes here.
</div>
</div>
the problem is you margin-left on the parent div. Change it to a percentage
Give Positions for your div's :
Parant Div :
position:relative;
Breadcrumb :
position:absolute;
Add media queries:
#media screen and (max-width: 800px) {
.breadcrumb {
max-width: 50%;
}
}
#media screen and (max-width: 750px) {
.breadcrumb {
max-width: 40%;
}
}

Absolute positioning of two inputs inside a div

I have a div that has a fixed position on a page. It holds two inputs, but the inputs aren't equally spaced inside the div.
HTML
<div class="submit_content">
<input class="btn" value="Cancel"/>
<input class="btn" value="Save"/>
</div>
CSS
.submit_content {
position: fixed;
text-align: center;
width: 50%;
margin-left: 20px;
right: 20px;
background-color: blue;
padding: 10px;
}
.submit_content input {
width: 30%;
height: 25%;
margin: 0 auto;
margin-right: 20px;
text-align: center;
padding: 5px;
}
How do I make the two inputs inside the fixed div equally spaced? The jsfiddle demo shows them hovering closer to the left because i have the margin-right set. Otherwise the inputs would be immediately next to each other. They should be separated, but the spacing inside the div should still be equal
It's simple. The right button also has a margin-right, thus (since the left button does not have a margin-left like the right button), they have a little different spacing.
To get rid of this issue, add this line:
.btn:last-child { margin-right:0; }
jsFiddle demo.
You can achieve this through adding this css to your code:
css
.submit_content input {
width:30%;
height:25%;
margin: 0 auto;
text-align:center;
padding:5px;
margin:5px;
}
See it work in fiddle.
Add this to your CSS
.submit_content input.btn:last-child {
margin-right:0 ;
}
DEMO

css issue in aligning 3 block equally spaced box

I have a template which has 3 equally spaced boxes, the problem is that i am unable to get the last box to align correctly the first two elements.
how do i add a 3 block equally spaced box in css without tables?
my attempt http://khine.3b1.org/activities/activities.html
any advise much appreciated.
thanks
Make all three boxes float left:
.box ul.supports-list li.last {
width: 200px;
position: relative;
float: left;
}
And provide more width overall:
.box .holder .frame {
background: url(./box-b.gif) no-repeat 0 100%;
width: 620px;
padding: 18px 4px 42px 16px;
}
try to change the next CSS rules to:
.box ul.supports-list {
font-size: 11px;
list-style: none outside none;
margin: 7px 0 0;
overflow: hidden;
padding: 0;
}
.box ul.supports-list li.supports-list-item {
display: list-item;
float: left;
outline-style: none;
width: 200px;
}
.box ul.supports-list li.last {
float: left;
width: 200px;
}
My guess would be to put each box into a div, and then adjust each div's margin-left and margin-top properties to get them to all line up. You'd also want to set the float property of all of the boxes to left. It might not be the most-widely-accepted way of doing things, but that's how I usually solve problems like this.
You can take a look at this example jsFiddle I did for you here: http://jsfiddle.net/Cwca22/g8x5E/ - Hope this helps!

CSS DIV Default width looks good in IE. Not Firefox

I've set up an example of what I'm running into here: http://studiozion.com/cssproblem/fix_it.htm.
Relevant code blocks...
<style type="text/css">
body
{
background: transparent url(Grade300_Color1.png) repeat-x
}
.RowMaker
{
overflow: auto;
}
.ColumnMaker
{
float: left;
}
.ColumnMaker2
{
float: right;
}
.PadTop
{
padding-top: 10px;
}
.PadBot
{
padding-bottom: 10px;
}
.PadLeft
{
padding-left: 15px;
}
.PadRight
{
padding-right: 15px;
}
.ControlCurve1
{
height: 6px;
background: transparent url(ControlCurve1.png) no-repeat right -6px
}
.ControlCurveRight1
{
height: 6px;
width: 6px;
background: transparent url(ControlCurve1.png) no-repeat top left
}
.ControlCurveLeft1
{
height: 6px;
width: 6px;
background: transparent url(ControlCurve1.png) no-repeat bottom left
}
</style>
<div class="RowMaker">
<div class="ColumnMaker ControlCurveLeft1"><span></span></div>
<div class="ColumnMaker ControlCurve1">
<div class="RowMaker">
<div class="ColumnMaker2 ControlCurveRight1"><span></span></div>
</div>
</div>
</div>
So the issue is that the div with class "ColumnMaker ControlCurve1" will expand to fill the width of parent container with class "RowMaker" in IE creating a nice little beveled cap for a div. But in Firefox the "ColumnMaker ControlCurve1" div truncates causing the right side of the beveled cap to be left aligned.
So who is right? And more importantly how do I go about fixing this while retaining the flexibilty of a visual element that expands to it's parent container? I really don't want to set a hard width on "ColumnMaker Control1".
you need to clear your floats. in your stylesheet, include the following code for the CONTAINER that has floats in it:
#yourContainer:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
you can also (and should also) clear your floats for IE by putting min-height: 10px; in your #yourContainer style definition.
It's also possible that because you have no content and have not set a width, the div will not stretch to anything.
Just some thoughts looking at it without really testing.
firefox is always the right one (j/k)
this problem has been solved many times before. may i suggest a quick search to find things like
http://redmelon.net/tstme/4corners/
http://kalsey.com/blog/2003/07/rounded_corners_in_css/
there is also a jquery solution
http://www.malsup.com/jquery/corner/