How can I align my search button to the right? - css

I'm not well versed in front end web design or CSS. Using a pre-made template from Foundation, however my code for a search button is not aligning like the example button.
Using this template: http://foundation.zurb.com/templates/workspace.html
Can someone tell me how I can move the search button to the right as in pic where the blue button is located?
This is what I am using now:
<input type="submit" value="Search" style="float: right;">
Fiddle: Search button code
<ul class="right">
<li class="search">
<li class="has-button">
/* Original template form */
{#<form>#}
{#<input type="search">#}
{#</form>#}
/* My form with code */
<form action="{{ path('sym_corp_search') }}" method="GET">
<label><input type="search" name="q" value={{ app.request.query.get('q') }}></label>
<input type="submit" value="Search" style="float: right;">
</form>
</li>
</li>
/* Original form button in blue */
<li class="has-button">
<a class="small button" href="#">Search</a>
</li>

Using the foundation classes, you can manage to perform this layout with your own inputs, your code will look like this:
<ul class="right">
<form action="{{ path('acme_demo_search') }}" method="GET">
<li class="search">
<label><input type="search" name="q" value="{{ app.request.query.get('q') }}" /></label>
</li>
<li class="has-button">
<input type="submit" value="Search" class="small button" />
</li>
</form>
</ul>

You have to use margin property like margin-left:50%; or more and you can also use ... tag but it will make button position to center. float:right is can be used in div, Not in button.

Move your button in a div :<div id="mybtn"><input type="submit" value="Search"></div> add CSS : #mybtn {float : right;display : inline-block;}

Related

changing styles of a class with its own id

I have a lot of form-controls in div classes of my website and i want to change the style of only 1 form-control. How it is possible? i tried to give an id but it did not work.
<ul className="nav navbar-nav navbar">
<li><input type="search" className="form-control" id="this" placeholder="Search" id="search_input" /></li>
<div className="col-sm-1">
<li><button type = 'button' onClick={submitSearch}>Search</button></li>
<li>
<div id="search_results">
</div>
</li>
</div>
</ul>
So i want to change the style of this form-control only! how should write is in my css file? Than you.
You've got 2 IDs on the same input..
<input type="search" className="form-control" id="this" placeholder="Search" id="search_input" />
That may be why you are having problems. Remove one of the IDs and then target the other via css.
<input type="search" className="form-control" placeholder="Search" id="search_input" />
input#search_input { /* css style here */ }
If you want to filter some selectors you can use pesudo element:
.form-control:first-of-type //First in its parent
.form-control:last-of-type //last in its parent
.form-control:nth-child(2) //.form-control only where it is second element of its parent

changing the default list colour of jquery mobile using css

I have an html page given below
<body>
<div data-role="page" id="home">
<div data-role="header" data-position="fixed">
</div>
<div data-role="content">
<div class="content-primary">
<form id="frm1">
<ul data-role="listview">
<li data-role="fieldcontain">
<label for="Name">name:</label>
<input type="text" Name="Name" id="Name" value="" />
</li>
<li data-role="fieldcontain">
<label for="No">no:</label>
<input type="text" No="No" id="No" value="" />
</li>
<li data-role="fieldcontain">
<label for="countryName">Country name:</label>
<input type="text" countryName="countryName" id="countryName" value="" />
</li>
<li data-role="fieldcontain">
<label for="stateName">State name:</label>
<input type="text" stateName="stateName" id="stateName" value="" />
</li>
<li data-role="fieldcontain">
<label for="cityName">City name:</label>
<input type="text" cityName="cityName" id="cityName" value="" />
</li>
</form>
</div>
</div>
</body>
and i am using the following jquery 1.3.2 links displayed in the link given
http://jquerymobile.com/download/
and i have css file given below
.ui-body-c { background:#FFFFFF !important; }
.ui-page .ui-header {
background:#0B0B3B !important;
}
.ui-page .ui-footer {
background:#0B0B3B !important;
}
When i am using the above code the list which is displayed contains grey color.
how will i get white color instead grey to the list displayed.
Thanks in advance
I can't actually test this but I have noticed oddities like this before when a css rule is defined as background-color: and you try to override with just background:
Try changing your rule to say background-color: instead. Also, if you can help it, stay clear of !important unless you're sure it's what you need. It can be a real pain when your css gets more complicated.
All you need is to set background-color rule to .ul-body
.ui-body{
background-color:#FFF;
}
Don't use !improtant, Keep it as a last resource.
Note: In case some other list might contain a class named ui-body, but you can give parent ID or class as selector to your custom class .ui-body
#Parent .ui-body{
}
.Parent .ui-body{
}
fiddle

On onClick, click a DIV so it expands

I want that if you click on text the search button appears, I try to do that by using this code:
<a class="gn-icon gn-icon-search" style="width:200%;" onClick="CLICK ON THE BUTTON DIV">Search with style</a>
<ul id="sb-search" class="sb-search" style="margin-right:30px;">
<span class="sb-icon-search"></span>
<form>
<input class="sb-search-input" placeholder="Please enter search terms" type="text" value="" name="search" id="search">
<input class="sb-search-submit" type="submit" value="" id="search-submit">
</form>
</div>
Does someone knows how to fix this? Maybe with jQuery? Thank you very much!
Using JQuery you can show the button on link click.
The HTML:
<a class="gn-icon gn-icon-search" id="search-text" style="width:200%;">Search with style</a>
<ul id="sb-search" class="sb-search" style="margin-right:30px;">
<span class="sb-icon-search"></span>
<form id="search-form">
<input class="sb-search-input" placeholder="Please enter search terms" type="text" value="" name="search" id="search">
<input class="sb-search-submit" type="submit" value="" id="search-submit">
</form>
</ul>
The JQuery:
$(document).ready(function() {
$('#search-form').hide();
});
$('#search-text').click(function() {
$('#search-form').show();
});

Wrap a contact form around background image

How do I wrap a contact form around a backgroud image (eg. a desktop screen). For further clarification, please visit this link. Scroll down to the bottom of the page and you'll see a mac screen background wraped inside of a login page.
<div id="new_div_3">
<form class="contact_form" action="#" method="post" name="contact_form">
<ul>
<li>
<h2>Contact Us</h2>
<span class="required_notification">* Denotes Required Field</span>
</li>
<li>
<label for="name">Name:</label>
<input type="text" placeholder="John Doe" required />
</li>
<li>
<label for="email">Email:</label>
<input type="email" name="email" placeholder="john_doe#example.com" required />
<span class="form_hint">Proper format "name#something.com"</span>
</li>
<li>
<label for="website">Website:</label>
<input type="url" name="website" placeholder="http://johndoe.com" required pattern="(http|https)://.+"/>
<span class="form_hint">Proper format "http://someaddress.com"</span>
</li>
<li>
<label for="message">Message:</label>
<textarea name="message" cols="40" rows="6" required ></textarea>
</li>
<li>
<button class="submit" type="submit">Submit Form</button>
</li>
</ul>
</form>
</div>
This is what i currently have in my new_div_3.
#new_div_3 {
margin:0 auto;
width: 500px;
background:#ECF0F1 url('img/email-screen.png') 0 0 no-repeat;
background-size: 1040px 878px;
padding: 38px 38px 267px;
}
Is there a way of making the background appear correctly, in the center of the div with the addition of the contact form appearing in the center too?
I think you're looking for something like:
background:#ECF0F1 url('img/email-screen.png') no-repeat center center;
If you are using firefox or chrome, you can use inspect element to see how it has been setup in the example you provided.

Twitter Bootstrap: using submit form as drop down menu items?

Instead of using anchors or buttons in a drop down menu, I want to have a form for each item. The form contains some hidden fields and a submit button. When I put the form in each <li> of my mark up, the UI was messed up. Does Bootstrap support this natively? If not, I'm going to re-code my application to work with links.
Update 1: screen shot
Update 2: mark up
<div class="btn-group open">
<button class="btn">Action</button>
<ul class="dropdown-menu">
<li>
<form action="#" method="post">
<fieldset>
<input type="submit" value="Favorite"/>
</fieldset>
</form>
</li>
<li>Message</li>
<li>
<form action="#" method="post">
<fieldset>
<input type="submit" value="Smile"/>
</fieldset>
</form>
</li>
<li>
<form action="#" method="post">
<fieldset>
<input type="submit" value="Block"/>
</fieldset>
</form>
</li>
<li>
<form action="#" method="post">
<fieldset>
<input type="submit" value="Friend"/>
</fieldset>
</form>
</li>
<li>
<form action="#" method="post">
<fieldset>
<input type="submit" value="Exclude From Future Search Results"/>
</fieldset>
</form>
</li>
</ul>
</div>
Update 3: icons
I want the submit buttons to have an icon. Not sure what's the best way to do that, but this is my solution:
<label for="foo">
<i class="icon-ok></i> Favorite
</label>
<input id="foo" style="display:none;" type="submit" value="Favorite"/>
The submit form is hidden, the label is shown with icon, and when user clicks on the label, it works. No JS required.
Not quite sure if I understand what you mean about the submit form being hidden but the label showing an icon however I was able to override the buttons with an image. Please see the attached jsBin. I did it by adding a class to the input's
http://jsbin.com/eboqij/1/edit
.button{
background-image:url('http://www.nyanicorn.com/res/img/icon_nyan.png');
background-repeat:no-repeat;
text-indent:-9999px;
width:40px!important;
}
Or just use Javascript to store the value in a hidden field and submit the form -- you're probably using JS anyways handle the open/close of the dropdown.
I had the exact same problem and I've created this new "submit" plug-in:
!function ($) {
"use strict"; // jshint ;_;
$(document).on('click.submit.data-api', '[data-submit]', function (e) {
e.preventDefault()
var form= $('#'+$(this).data('submit'))
form.find('input[name="'+$(this).data('name')+'"]').val($(this).data('value'))
form.submit()
})
}(window.jQuery);
Which I can use thus:
<form id="myform" ...>
<input type="hidden" name="myparam">
<div class="btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
Action
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>
<a data-submit="myform" data-name="myfield" data-value="myvalue>
Click here
</a>
</li>
</ul>
</div>
</form>

Resources