Cakephp horizontal checkboxes - css

I'm trying to get a list of checkboxes to display across the page instead of vertically
I've read numerous posts in SO and others, and it appears I'm doing the correct thing, but my checkboxes refuse to float horizontally. I've tried a number of solutions including inline styling and assigning a different class in the code. Can someone spot my error please?
Cake Code
<?php
echo $this->Form->input('Check.Assessment', array( 'multiple' => 'checkbox')); // checkboxes
?>
Generated HTML
<div class='assessments'>
<div class="input select"><label for="CheckAssessment">Assessment</label><input type="hidden" name="data[Check][Assessment]" value="" id="CheckAssessment"/>
<div class="checkbox"><input type="checkbox" name="data[Check][Assessment][]" value="1" id="CheckAssessment1" /><label for="CheckAssessment1">Blah</label></div>
<div class="checkbox"><input type="checkbox" name="data[Check][Assessment][]" value="2" id="CheckAssessment2" /><label for="CheckAssessment2">Blah Blah</label></div>
<div class="checkbox"><input type="checkbox" name="data[Check][Assessment][]" value="3" id="CheckAssessment3" /><label for="CheckAssessment3">Blah Blah Blah</label></div>
<div class="checkbox"><input type="checkbox" name="data[Check][Assessment][]" value="4" id="CheckAssessment4" /><label for="CheckAssessment4">Blah Blah Blah Blah</label></div>
</div>
CSS
.checkbox
{
float: left;
padding-right: 15px;
}

I fixed a nice demo fiddle for you
https://jsfiddle.net/wgrLfxg3/15/
Just fixed the css display:box like this
.checkbox
{
padding-right: 15px;
display:box;
}
If you want margin between divs just add
padding-bottom:10px
or something like this.
If you want them to float left just set
left:0;
EDIT:
If what you need is to have them inline just add the display:inline-block, here is the demo for this
https://jsfiddle.net/wgrLfxg3/19/

Related

Styling option tags

I have a drop down that contains options. I would like to partially break & bold some text as well as insert context breaks. I tried using CSS as well as HTML tags but I'm unable to get it. Can someone please suggest a solution?
Thanks in advance
I know this question is a bit old (or not new at least), but I'd like to show a very simple way to emulate a select element rather than using a "replacement plugin" as suggested in How to style the option of a html “select”?.
There are probably many, MANY ways to do this, but I try to keep things extremely simple, so my method of emulation only uses CSS. It is rather bare bones, but I'd like to point out that it is not a complicated thing to do so you might not need a plug in to do it.
Note1: Instead of using <option>, I used <label>. Since <label> is an interactive element, putting something interactive inside (like a <button>) would probably mess it up. Options are normally non-interactive anyway, but just be aware that this simple emulation can't do everything.
Note2: If you want to be able to select multiple options, just do a search for "radio" and replace with "checkbox".
Emulating Select Using Radio - No Collapse
input[type="radio"] {
display: none;
}
input[type="radio"]:checked + label {
background-color: black;
color: #28AADC;
}
/* none functional styles. just regular styling */
.radio_select {
background-color: #28AADC;
display: inline-block;
}
<div class="radio_select">
<div>
<input id="rad1" type="radio" name="radio_select" />
<label for="rad1">Option 1</label>
</div>
<div>
<input id="rad2" type="radio" name="radio_select" checked="checked" />
<label for="rad2">Option 2</label>
</div>
<div>
<input id="rad3" type="radio" name="radio_select" />
<label for="rad3">Option 3</label>
</div>
</div>
Radio select emulation - with collapse
Note: this won't work for mobile devices since it uses :hover.
input[type="radio"] {
display: none;
}
/* style this to your heart's content */
input[type="radio"] + label {
display: none;
}
input[type="radio"]:checked + label {
background-color: black;
color: #28AADC;
display: inline-block;
}
.radio_select:hover label {
display: inline-block;
}
/* none functional styles. just regular styling */
.radio_select {
background-color: #28AADC;
display: inline-block;
}
<!-- NOTE: This technique uses hover, so it won't work for mobile devices.
I couldn't think of a pure CSS way to solve that. Sorry. -->
<div class="radio_select">
<div>
<input id="rad1" type="radio" name="radio_select" />
<label for="rad1">Option 1</label>
</div>
<div>
<input id="rad2" type="radio" name="radio_select" />
<label for="rad2">Option 2</label>
</div>
<div>
<input id="rad3" type="radio" name="radio_select" checked="checked" />
<label for="rad3">Option 3</label>
</div>
</div>

How do I make the width/length of a form field longer using CSS?

I have a form field box with class CCPPDisplayTD.
I'm trying to make it's length longer with CSS styling.
How do I use CSS to accomplish this?
<form>
<input type="text" /><br />
<input type="text" class="CCPPDisplayTD" />
</form>
.CCPPDisplayTD{
width: 200px;
}
See here: http://jsfiddle.net/GT8jD/
In your stylehseet you need the following:
.CCPPDisplayTD{
width: 250px; // whatever size you need.
}
Your HTML needs to resemble something similar to:
<form>
<label> /* Label elements are required for better accessibility */
<input type="text" class="CCPPDisplayTD" />
</label>
</form>
Or the following:
<form>
<label for="input-name"> /* Label elements are required for better accessibility */
<input type="text" class="CCPPDisplayTD" id="input-name" name="input-name" />
</label>
</form>

Change text location in CSS

I'm currently using following login form where I want to change the design a bit:
http://html-form-guide.com/php-form/php-login-form.html
I want to place ' Login ' into the middle of the box, instead the left:
I've also found out that you can change the textsize, font etc. in fg_membersite.css (line 17). What's interesting is that in Chrome it IS displayed in the middle, only in Firefox it's shown on the left. Since I'm a new CSS worker I wanted to ask if anybody could help me fixing this incompatiblity problems here.
Since it also contains lots of Javascript based stuff I wasn't sure if I posting source codes here would be sensible, because I'd have to post the whole source anyway then.
Thanks in advance!
EDIT: Much prettier now. Thanks:
http://rapidhdd.com/images/4013242013-10-06_1842.png
Use this for the center text part:
<form id='login' action='login.php' method='post' accept-charset='UTF-8'>
<fieldset >
<legend align="center">Login</legend>
<input type='hidden' name='submitted' id='submitted' value='1'/>
<label for='username' >UserName*:</label>
<input type='text' name='username' id='username' maxlength="50" />
<label for='password' >Password*:</label>
<input type='password' name='password' id='password' maxlength="50" />
<input type='submit' name='Submit' value='Submit' />
</fieldset>
</form>
I guess you've changed the HTML code but note the: <legend align="center">Login</legend>
align="center"
http://jsfiddle.net/4szBC/
EDIT:
Since it seems like align is deprecated you, can do this using by using css.
legend {
text-align: center;
}
If you want the css right in HTML, add it in a <script> tag and place it in <head>. Like this:
<script type="text/css">
legend {
text-align: center;
}
</script>
http://jsfiddle.net/4szBC/1/
add to submit button few CSS rules:
input[type=submit] {
display: inline-block;
margin: 0 auto;
padding: 10px 30px;
}

My asp.net page cause scroll up.. only in case of Firefox

In my ASP.net page, which does have scroll bar, I have placed a customized control in which I have used a HTML check box (it's like hierarchical structure).
When I scroll down the page (to reach to that control) and then I select any item from that check box, the page scrolls up to the top of the page, without causing post back.
How can I stop the scrolling issue from happening?
Note: It only happens with Firefox, it doesn't happens on other browsers i.e IE 8/9 & Chrome.
This is my customized control, which I have used in My another asp.net page,is when i check any of the bellow items. it causes scroll up of page.
<asp:Panel ID="TreeViewPanel" runat="server" style="border: 1px solid #CCC; width: 210px; padding:5px 0;">
<ul id="tree">
<li>
<label>
<input type="checkbox" value="treeHdrCheck1" runat="server"/>Win Exe
</label>
<ul>
<li>
<label>
<input type="checkbox" value="1" runat="server"/>.EXE</label></li>
<li>
<label>
<input type="checkbox" value="2" runat="server"/>.DLL</label></li>
<li>
<label>
<input type="checkbox" value="3" runat="server"/>.OCX</label></li>
<li>
<label>
<input type="checkbox" value="4" runat="server"/>.SYS</label></li>
<li>
<label>
<input type="checkbox" value="5" runat="server"/>.SCR</label></li>
</ul>
</li>
Are you styling your checkboxes?
If you use CSS like
label {
display: block;
overflow: hidden;
}
label input[type="checkbox"] {
position: absolute;
left: -10000px;
top: -10000px;
}
to hide the actual input element from the containing label, then you may need to remove the top: -10000px; part, because Firefox seems to be wanting to scroll the input element into view.

Align button to input with float?

How can I align button right next to my input text. Example here
HTML
<div id="frm">
<label>Select an Item:
<input type="text" /><input type="button" value="..." class="open">
</label>
<label>Price:<input type="text" /></label>
CSS
#frm label
{
display:block;
float:left;
padding-right:6px;
}
#frm input
{
display:block;
}
Edit
I want my form elements horizontally aligned in blocks & I like the popup button to align with just one textbox.
I'd suggest to move the <input> outside the <label>, like this:
<div id="frm">
<div class="group">
<label for="item">Select an Item:</label>
<input type="text" id="item" />
<input type="button" value="..." class="open">
</div>
<div class="group">
<label for="price">Price:</label>
<input type="text" id="price" />
</div>
</div>
If you want to separate the inputs from the label, you should place the label text inside an own element, and not mix label text and input into a common tag.
Then, you can use the following CSS:
#frm .group {
display: block;
float: left;
padding-right: 6px;
}
#frm label {
display:block;
}
See how it looks like, is this what you want?
-Easiest way to solve your problem, is to remove all CSS - input is inline by default, so it won't wrap to the next line if you add no CSS.
-And I'd add an extra div to make sure your fields are on seperate lines, no CSS needed either.
Like this:
<div id="frm">
<div class="field">
<label>Select an Item:</label>
<input type="text"><input type="button" value="..." class="open">
</div>
<div class="field">
<label>Price:</label>
<input type="text">
</div>
</div>
http://jsfiddle.net/ckfZE/15/
http://jsfiddle.net/ckfZE/18/
added a span-tag though
This CSS is causing that conflict:
#frm input {
display:block;
}
You could set .open to display:inline to fix this.
Be a little more specific with your question. If you took the CSS out completely they would be aligned right next to each other. If you want them on separate lines add a <br/> after the text input.

Resources