I am trying to create a shopping list. The list is dynamically created using Javascript (jQueryUI). I want the thrash cans next to be on the right side (where this blue dots that I draw are). I tried to do it using left or style="right:350px" and float:right in tag but it didn't work.
Here is my code where it's row is generated:
var row=$('<div class"productsclass" id='+selectedproducts[i]+' style="width:400px">
<label style="font-size:20px">'+selectedproducts[i]+'</label><input type="text"
name="Quantity" value="1" id='+thesi+'><img class=delete
src="http://b.dryicons.com/images/icon_sets/handy_part_2_icons/png/128x128/recycle_bin.png"
height="22" width="22" style="right:350px"></div>');
rowID++;
$("#productstable").append(row);
Here is the html:
<div id="maindiv" class="maindiv">
<input id="autocomplete_text_field">
<button id="add_product_button">Add product</button>
<form action="#" id="productstable" name="productstable">
<p></p>
</form>
</div>
</body>
and here is the CSS:
#body{
background-color: #6E0D25
}
#maindiv {
position:absolute;
top: 50%;
left: 50%;
width:30em;
height:18em;
margin-top: -9em; /*set to a negative number 1/2 of your height*/
margin-left: -15em; /*set to a negative number 1/2 of your width*/
/*border: 1px solid #ccc;*/
background-color: #6E0D25;
}
#productstable
{
background-color:#F1EBE4;
border-radius:10px;
width:400px;
}
#product
{
width:380px;
}
#autocomplete_text_field
{
width:200px;
height:40px;
border-radius:10px;
}
#add_product_button
{
width:200px;
height:50px;
border-radius:10px;
}
How can I do it?
(Sorry if it is a very useless question, It's almost the first time I use CSS)
Solved after user2313440's answer:
Change img class=delete to img class="delete" then add float:right; to it in CSS.
just a simple rearrange of your img, and using float: right;
try this code instead:
var row=$(' <div class "productsclass" id='+selectedproducts[i]+' style="width:400px">
<img class=deletesrc="http://b.dryicons.com/images/icon_sets/handy_part_2_icons/png/128x128/recycle_bin.png" height="22" width="22" style="float: right;">
<label style="font-size:20px">'+selectedproducts[i]+'</label>
<input type="text" name="Quantity" value="1" id='+thesi+'>
</div>');
rowID++;
$("#productstable").append(row);
Related
I have been attempting to solve this phenomina using style="overflow: hidden; padding-right: .5em;". The search button still appears at the bottom left and creates an "l" shape. If any has ideas as to why this happens it would help
#searchbartop{
margin:auto;
vertical-align:middle;
position:absolute;
margin-left:25%;
}
#searchbartoptext{
width:600%;
}
<form id="searchbartop">
<input type="text" placeholder="Search..." id="searchbartoptext" style="overflow: hidden; padding-right: .5em;" required>
<input type="button" style="width: auto;" value="Search">
</form>
You can try like this: Demo
#searchbartop {
margin:auto;
vertical-align:middle;
margin-left:25%;
width:75%;
}
#searchbartop input[type=text] {
width:70%;
padding-right: .5em;
display:block;
float:left;
}
#searchbartop input[type=button] {
width:20%;
display:block;
float:left;
}
HTML:
<form id="searchbartop">
<input type="text" placeholder="Search..." required/>
<input type="button" value="Search" />
</form>
You may have to set the search button to position:absolute; as is the case in this Fiddle
i am struggling to place input check-box in same line x-horizontal as in label. My check-box is placing in 2nd line. I have a div with background to image then label and then check-box. The margin between image and label div and margin between label and check need to be same. Many thanks in advance.
<div id="map_Marker_Check_Block">
<div class="markerDiv" id="maker_school"><div class="marker_label">School</div> <input class="marker_ckeckbox" name="markerType" value="school" type="checkbox" /> </div> <br />
<div class="markerDiv" id="maker_gym"> <div class="marker_label">Gym</div> <input class="marker_ckeckbox" name="markerType" value="gym" type="checkbox" /> </div><br />
</div>
css
#map_Marker_Check_Block {
background-color:yellow;
display:block;
position:absolute;
width:20em;
height:400px;
top:0;
right:0;
z-index:10;
overflow-y:auto;
}
.marker_label {
margin-left:50px;
line-height:48px;
width:130px;
background-color:green;
}
.marker_ckeckbox {
float:right;
}
.markerDiv {
width:19em;
height:48px;
margin-left:5px;
}
#maker_school { background: url("img1.png") no-repeat; }
#maker_gym{ background: url("img2.png") no-repeat; }
http://jsfiddle.net/XUErp/
.marker_label {
float:left;
margin-left:50px;
line-height:48px;
width:130px;
background-color:green;
}
.marker_ckeckbox {
margin-top:15px;
float:right;
}
Use TOP and POSITION styles for checkbox:
.marker_ckeckbox {
float: right;
position: relative;
top: -35px;
}
But, I think the elements must be structured in a different way.
Or as Musa said use label instead of div:
Sample: http://jsfiddle.net/qaprB/1/
try this
<div class="markerDiv" id="maker_school"><label class="marker_label">School</label> <input class="marker_ckeckbox" name="markerType" value="school" type="checkbox" /> </div> <br />
<div class="markerDiv" id="maker_gym"> <label class="marker_label">Gym</label> <input class="marker_ckeckbox" name="markerType" value="gym" type="checkbox" /> </div><br />
css
.marker_ckeckbox {
float:right;
position: relative;
top: -35px;
}
.marker_label {
display:block;
}
I want to center the div box im making here but i dont want to center the text in the box and i cant seem to find how to do this. For now what i have is this:
.box {
text-align: left;
background-color:#3F48CC;
color:white;
font-weight:bold;
margin:120px auto;
height:150px;
display: inline-block;
width: 200px;
}
and
<div class=box>
Login
<form method ="post" action="addMember.php">
<label for="name">Username:</label>
<input name="name"/>
<label for="password">Password:</label>
<input name="password"/>
<p>
<input name="submit" type="Submit" value="Register"/>
<input name="reset" type="reset" value="Clear Form">
</form>
</div>
Thanks in advance!
Remove display: inline-block; & text-align:center
inline-block is not necessary when you are defining the width/height for the div.
By default div is a block element.
.box {
background-color:#3F48CC;
color:white;
font-weight:bold;
margin:120px auto;
height:150px;
width: 200px;
}
DEMO
Use dead centre...
.box {
text-align: left;
background-color:#3F48CC;
color:white;
font-weight:bold;
height:150px;
width: 200px;
position: absolute;
left: 50%;
top: 50%;
margin-left: -100px;
margin-top: -75px;
}
Note: Negative margins are exactly half the height and width, which pull the element back into perfect center. Only works with elements of a fixed height/width.
More info:
CSS Tricks Example
jsFiddle Demo
jsFiddle DEMO
Alternate jsFiddle DEMO with Centered Form and also this CSS3 Version.
The key to making the form look correct is to use padding, which is part of box model. Doing so allows you to fill in the sides, and keeps the text left-hand aligned.
HTML
<div class=box>Login
<form method="post" action="addMember.php">
<label for="name">Username:</label>
<input name="name" />
<label for="password">Password:</label>
<input name="password" />
<div class="buttons">
<input name="submit" type="Submit" value="Register" />
<input name="reset" type="reset" value="Clear Form" />
</div>
</form>
</div>
CSS:
.box {
background-color:#3F48CC;
color:white;
font-weight:bold;
height:150px;
width: 150px;
padding: 10px;
}
.buttons{
padding-top: 20px;
}
Screenshot:
I've got a website that has a big image covering the screen. In its image there are several DIVs (Text, Forms, Images) (see picture 2). The big image container is made displaying always the center of the image regardless of window size, so when you make your windows smaller, the very center stays visible.
The problem now is that the DIVs are collapsing, when I scale down the window size (see picture 3).
Picture number 2 depicts what it is intended to be look like!
#div1 {
width:25%;
left: 32%;
top:7.5%;
position: relative;
float:left;
}
#div2 {
position:relative;
left:37.5%;
clear:both;
width:14%;
height:20%;
}
#div2 h2 {
width:10%;
left:15%;
margin-top:11%;
position: relative;
float: left;
}
#div3 {
left: 64.4%;
top:-2.5%;
width:111px;
position: relative;
}
#div4{
left: 93%;
top:-18.0%;
width:111px;
position: relative;
}
And HTML:
<body>
<div id="wrapper"\>
<div id="div1">
<h1>Seite nicht gefunden!</h1>
</div>
<h2>Bug melden</h2>
<div id="div2">
<form>
<label>Titel</label>
<input type="text" id="form_title" name="title" placeholder="Ich will einen Bug melden!" required>
<label>URL</label>
<input type="url" id="form_url" name="URL" placeholder="###" >
<label>Beschreibung</label>
<textarea type="text" id="form_whathappened" name="happened" placeholder="Was ist passiert?" required></textarea>
<input type="submit" value="Absenden" />
</form>
</div>
<div id="div3">
<img src="logo.png" alt="Logo" />
</div>
<div id="div4">
<p>Jetzt<br/ >Tester<br />werden!<br /></p>
</div>
</div>
</body>
Can you please help me what I'm doing wrong? Thank you very much in advance!
Christoph
This is probably way far from perfect, but it's worth trying.
The html code:
<head>
<meta charset="utf-8">
<title>404</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="wrapper">
<div id="error">
<h1>Seite nicht gefunden!</h1>
</div>
<form id="form">
<h2>Bug melden</h2>
<label>Titel</label>
<input type="text" id="form_title" name="title" placeholder="Ich will einen Bug melden!" required>
<label>URL</label>
<input type="url" id="form_url" name="URL" placeholder="http://www.###/???" >
<label>Beschreibung</label>
<textarea type="text" id="form_whathappened" name="happened" placeholder="Was ist passiert?" required></textarea>
<input type="submit" value="Absenden" />
</form>
... //other code goes here</div>
and this is the edited section of the css code:
#wrapper { width: 640px; height: auto; margin: 0 auto; }
#error { font-size: 120%; margin: 65px 0 0 60px; float:left; }
#error h1 { font-size: 150%; text-align:center; }
#form { margin: 15px 86px; width:260px; height: 40%; float: left; background: green; }
Check the working example here: example
Hope that helps as a start.
I have to create an input box with the following background
So far in my code I have the code below and its not showing -> What would be the correct procedure to do this?
I also have a couple of variations of this button I have to produce and they are the following:
A cross on the dark area of the button - I was just going to use a <span> tag with a class and set the graphic to that -> Would this be a good way to go?
A paper clip icon just after the curve on the left -> I was going to do the same as above -> Would this be a good way to go?
HTML:
<div class="innerTo">
<form action="#" method="get">
<label for="recipients">TO: </label>
<input type="search" name="recipients" id="recipients" placeholder="Recipients Names">
</form>
</div>
CSS:
.innerBar .innerTo{
width:200px;
padding:5px 0 0 15px;
display:block;
float:left;
}
.innerBar .innerTo label{
margin:0 15px 0 0;
font-size:14px;
font-weight:bold;
color:#666666;
}
.innerBar .innerTo input[type=search] {
color: red;
}
.innerBar .recipients{
background-image:url('../images/searchBGpng.png') no-repeat;
width:192px;
height:27px;
}
Fiddled:
<div class="input-container">
<input type="text" value="aaaaaaaaaaaaaaaaaa"/>
</div>
.input-container {
background: url(http://i.stack.imgur.com/0Vlc5.png) no-repeat;
width:197px;
height:28px;
}
.input-container input{
height:28px;
line-height:28px;/*results in nice text vertical alignment*/
border:none;
background:transparent;
padding:0 10px;/*don't start input text directly from the edge*/
width:148px;/*full width - grey on the side - 2*10px padding*/
}
If you're planning to reuse it with different widths, you should look up the sliding doors technique.
I have created new code for your form if you like this, then go ahead and apply it to your html code
You can do this
HTML Code
<form action="#" method="get">
<label for="recipients">TO: </label>
<input type="search" name="recipients" id="recipients" placeholder="Recipients Names">
<input type="submit" value="">
</form>
Css Code
label{
float:left;
margin:25px 0 0 0px;
padding:0;
}
input[type="search"], input[type="submit"]{
margin:20px 0 0 0px;
padding:0;
line-height:28px;
height:28px;
background: url("http://i.stack.imgur.com/0Vlc5.png") no-repeat 0 0;
border: 0 none;
float:left;
}
input[type="search"]{
width:152px;
padding-left:15px;
}
input[type="submit"]{
background-position:-167px 0;
width: 30px;
cursor:pointer;
}
Live demo link here http://jsfiddle.net/AL6vb/4/
Now change to code according your layout this is only demo .......