CSS positioning of JS dropdown - relative to fluid searchbar width - css

I'm working on a searchbar that has a js dropdown for categories. The searchbar needs to be responsive to width changes and at the moment the general layout is fine. I'm having one problem of positioning the dropdown menu relative to the category button. As it is now, the dropdown pushes the searchbar content down.
I have applied z-index, but no joy.
I have put the category dropdown within the new-sb-container, but still no joy. Any help greatly appreciated.
<div id="new-sb-container">
<div id="search">
<form id="search-form" method="post" action="">
<input type="text" name="q" id="query" placeholder="Search..."/>
<div id="search-category" title='Select a search category'>All Categories</div>
<div id="search-category-menu">
<label id='search-options'>Search Options:</label><br/>
<input type="radio" name="search_category" id='all_categories' value="all" checked><label for='all_categories'>All Categories</label><br/>
<input type="radio" name="search_category" id='antiques' value="antiques"><label for='antiques'>Antiques</label><br/>
</div> <!--end category menu-->
</form>
</div> <!--end search container-->
<div id="search-submit"><form><input type="submit" id='search-submit' value="Search"></form> </div>
</div><!--end sb container-->
#new-sb-container{
clear:both;
overflow:hidden;
width: 60%;
margin-top: 20px;
}
div#search
{
overflow:hidden;
width: 70%;
background-color: #FFFFFF;
border: 1px solid #CCCCCC;
border-top-left-radius: 7px;
border-bottom-left-radius: 7px;
padding-left: 10px;
float:left;
z-index: 1;
position:relative;
}
#search-form{
position: relative;
float:left;
width: 100%;
z-index: 0;
}
input#query{
position:relative;
float:left;
width: 60%;
height: 27px;
border: 1px solid #FFFFFF;
overflow:hidden;
}
div#search-category /*grey category box*/
{
border-radius: 7px;
font-family: Verdana,Arial,sans-serif;
font-size: 11px;
display:inline;
background-color: #CCCCCC;
padding-top: 5px;
padding-bottom: 5px;
padding-left: 7px;
padding-right: 7px;
cursor: default;
margin-right:5px;
float:right;
}
div#search-category-menu
{
float:right;
position:relative;
width: 150px;
background-color: #FFFFFF;
border: 1px solid #000000;
padding: 8px;
margin-top: 10px;
z-index:99;
float:right;
}
div#search-submit{
position:relative;
float:left;
width:20px;
}
As the code stands the search-category-menu is relative to search-form > search > sb-new container.
and the jq form if this help...
$(document).ready(function()
{
function search_autocomplete(selector, tags, default_value)
{
$('#' + selector).focus(function()
{
if($('#' + selector).val() == default_value)
{
$('#' + selector).val('');
}
});
$('#' + selector).blur(function()
{
if($('#' + selector).val() == '')
{
$('#' + selector).val(default_value);
}
});
var search = $('#' + selector).autocomplete(
{
source: tags,
timeout: 0,
select: function(event, ui)
{
var selected_object = ui.item;
var search = selected_object.value;
search = search.replace(/\s+/g, '-').toLowerCase();
var category = $('input[name="search_category"]:checked').val();
$("#search-form").attr("action", "/search/" + search + "/category/" + category);
$("#search-form").submit();
}
});
$('#' + selector).data('ui-autocomplete')._renderItem = function (ul, item)
{
var re = new RegExp('^' + this.term, "i");
var t = item.label.replace(re, "<span id='dropdown-item-highlight'>" + "$&" + "</span>");
return $('<li></li>')
.data("item.autocomplete", item)
.append('<a> ' + t + '<span id="dropdown-category"> in ' + item.type + '</span></a>')
.addClass( 'dropdown-item' )
.appendTo(ul);
$('<li></li>').append('<a>Hide suggestion</a>').appendTo(ul);
};
$('#' + selector).data('ui-autocomplete')._renderMenu = function (ul, items)
{
var that = this;
$.each( items, function( index, item )
{
that._renderItemData( ul, item );
});
$(ul)
.attr( 'tabindex', -1 )
.addClass('dropdown-menu');
$('<li></li>')
.append('<a>Hide Suggestion</a>')
.addClass( 'dropdown-suggestion' )
.appendTo(ul);
};
}
$('#search-category-menu').hide();
$('#search-category-menu input[type="radio"]').click(function()
{
var category = $(this).next("label").text();
$('#search-category').text(category);
$('#search-category-menu').hide();
//not focusing by selector
$('#query').focus();
});
$('#search-category').click(function()
{
if ($('#search-category-menu').is(":visible"))
{
$('#search-category-menu').hide("fast");
}
else
{
$('#search-category-menu').show("fast");
}
});
var availableTags = [{"label" : "XBOX 360", "type":"Electronics"},
{"label":"XBOX One", "type":"Electronics"},
{"label":"Nike", "type":"Clothing & Footwear"}];
search_autocomplete('query', availableTags, 'Search...');
});

Fixed with the folowing
take category drop down out of container.
place a span element with width at similar percentage as category button movement.
make drop down relative to absolute span
apply z indexes to span and drop down.
code below
<div id="new-sb-container">
<div id="search">
<form id="search-form" method="post" action="">
<input type="text" name="q" id="query" placeholder="Search..."/>
<div id="search-category" title='Select a search category'>All Categories</div>
</form>
</div> <!--end search container-->
<div id="search-submit"><form><input type="submit" id='search-submit' value="Search"></form></div>
</div><!--end sb container-->
<span id = "menuplacer">
<div id="search-category-menu">
<label id='search-options'>Search Options:</label><br/>
<input type="radio" name="search_category" id='all_categories' value="all" checked><label for='all_categories'>All Categories</label><br/>
<input type="radio" name="search_category" id='antiques' value="antiques"><label for='antiques'>Antiques</label><br/>
</div> <!--end category menu-->
</span>
#menuplacer{
clear:both;
width:41%;
position: absolute;
}
div#search-category-menu
{
width: 150px;
background-color: #FFFFFF;
border: 1px solid #000000;
padding: 8px;
margin-top: 10px;
z-index:1000;
position:relative;
float:right;
}

Related

css button is moving after adding a field in an upper list

Hello guys !
So that's the problem : I've 3 tables which are 3 items lists. I've 2 buttons (cancel/submit) below the lists. When I add a row in one of the lists : the buttons below escapes, moving right. What the heck ?
If someone has an idea of how to fix it, it'll save me some hair : https://jsfiddle.net/sqonLbv4/
Thanks a lot
HTML
<div class="cols3">
<label for="field1">Field 1</label>
<table id="tableField1"></table>
<input id="field1" name="field1" type="text" />
<button id="field1Add" name="field1Add" class="btn btnOrange" type="button" onclick="field1Add()">Add</button>
<button id="field1Delete" name="field1Delete" class="btn btnBlack" type="button" onclick="field1Delete()">Delete last</button>
</div>
<div class="cols3">
<label for="field2">Field 2</label>
<table id="tableField2"></table>
<input id="field2" name="field2" type="text" />
<button id="field2Add" name="field2Add" class="btn btnOrange" type="button" onclick="field2Add()">Add</button>
<button id="field2Delete" name="field2Delete" class="btn btnBlack" type="button" onclick="field2Delete()">Delete last</button>
</div>
<div class="cols3">
<label for="field3">Field List 3</label>
<table id="tableField3"></table>
<input id="field3" name="field3" type="text" />
<button id="field3Add" name="field3Add" class="btn btnOrange" type="button" onclick="Field3Add()">Add</button>
<button id="field3Delete" name="field3Delete" class="btn btnBlack" type="button" onclick="field3Delete()">Delete last</button>
</div>
</div>
<div id="btnsForm" class="subcontainer">
<button id="btnCancel" name="btnCancel" class="btn btnBlack" type="button">Cancel</button>
<button id="btnSubmit" name="btnSubmit" class="btn btnOrange" type="submit">Submit</button>
</div>
JS
var field1 = document.querySelector("#field1");
function field1Add() {
var table = document.querySelector("#tableField1");
var cell = table.insertRow(0).insertCell(0);
cell.innerHTML = field1.value;
}
function field1Delete() {
var table = document.querySelector("#tableField1");
table.deleteRow(0);
}
var fieldList2 = [];
var field2 = document.querySelector("#field2");
function field2Add() {
var table = document.querySelector("#tableField2");
var cell = table.insertRow(0).insertCell(0);
cell.innerHTML = field2.value;
}
function field2Delete() {
var table = document.querySelector("#tableField2");
table.deleteRow(0);
}
var fieldList3 = [];
var field3 = document.querySelector("#field3");
function field3Add() {
var table = document.querySelector("#tableField3");
var cell = table.insertRow(0).insertCell(0);
cell.innerHTML = field3.value;
}
function field3Delete() {
var table = document.querySelector("#tableField3");
table.deleteRow(0);
}
CSS (aka the devil)
box-sizing: border-box;
}
.subcontainer {
padding: 0 2rem;
}
.cols3 {
width: 33%;
float: left;
padding: 0 0.3rem 3rem;
}
.btn {
color: #fff;
font-size: 1rem;
font-weight: 700;
background-color: transparent;
border: 1px solid transparent;
border-radius: 0;
cursor: pointer;
display: inline-block;
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.btnCentered {
text-align: center;
}
.btnTitle {
vertical-align: middle;
margin-left: 2rem;
}
.btnOrange {
background-color: chocolate;
border-color: chocolate;
}
.btnOrange:hover {
color: #fff;
background-color: #000;
border-color: #000;
}
.btnBlack {
color: #000;
border-color: #000;
}
.btnBlack:hover {
color: #fff;
background-color: #000;
border-color: #000;
}
.btnBlack:active {
color: #f16e00;
border-color: #f16e00;
}
.btnsTable {
white-space: initial;
}
#btnsForm {
text-align: center;
}
You shouldn't be using float: left to position things next to each other in this case. In this case you'd rather want to use a flexbox. Change the css to this to have it display next to each other:
.cols3 {
width: 33%;
padding: 0 0.3rem 3rem;
}
#numbers {
display: flex;
justify-content: space-between;
}
edit: There are way better ways to position things on certain places nowadays. If you want to position multiple elements on either the X axis or Y axis there is what we call a flexbox. If you want to position multiple elements on both the X axis AND Y axis, there is a grid.
Found it !
.cols3 {
width: 33%;
padding: 0 0.3rem 3rem;
}
.subcontainer {
display: flex;
}
For the HTML part, all the titles h3 have been moved before the div subcontainer.
With that, it's all fixed.
But like Terry said, the grid properties should have been used, it's better when you try to arrange objects on X & Y position.
Thanks

Can't find div for styling (tranform zoom) in javascript script tag in shadow dom of polymer 2.0 element

I am creating a polymer 2.0 PWA / Website. I have a problem with accessing a div container (I wish to zoom in and zoom out the div based on a user input).
In shadow dom with template dom if I am not able to get the element in Javascript so that on user action (like button click or slider) movement I can zoom the div.
I tried document getElementsByClassName, shadowroot search. I can see in shadow dom that this div is present. just not able to access it in javascript function in Polymer.
var ele = document.getElementsByClassName('containerMap')[0]; //
returns null in console can't find the element in shadow Dom
var el = this.shadowRoot.querySelector('someid'); // returns
null in console also tried '#someid' still null
console.log('shadowRoot el = '+JSON.stringify(el));
var elx = document.getElementById('someid'); // returns null in
console
console.log('shadowRoot el = '+JSON.stringify(elx));
//var el = this.$.someid; // does not find the element
// tried this.$['#someid'] this.$$('#someid') // does not work
console.log(el);
Here's the full code (removed few unwanted code elements so that focus is on the problem in hand)
MyApp.html
<link rel="lazy-import" href="epicsprint-page.html">
<dom-module id="my-app">
<template is="dom-bind">
<style>
....
</style>
....
<app-header-layout >
<div style="float:left; width:100%;">
<div style="float:left; width:10%;">
<paper-icon-button id="menuElement" icon="icons:menu" drawer-toggle halign="left"></paper-icon-button>
</div>
</div>
<div fit class="content">
<!-- IRON PAGES MAIN CONTENT -->
<iron-pages
selected="[[page]]"
attr-for-selected="name"
fallback-selection="not-found-404"
role="main">
<epicsprint-page name="epicsprint-page" user="{{user}}"
signedin="{{signedIn}}" statusknown="{{statusKnown}}" >
</epicsprint-page>
.....
</div>
</app-header-layout>
</app-drawer-layout>
</template>
</template>
<script>
</script>
...
window.customElements.define(MyApp.is, MyApp);
</script>
</dom-module>
Element: epicspring-page.html
<dom-module id="epicsprint-page">
<template is="dom-bind">
<style include="shared-styles">
:host {
padding: 10px;
font-family:'Fira Sans', sans-serif;
}
a paper-button,
a:hover paper-button,
a:link paper-button,
a:active paper-button,
a:visited paper-button {
width: 20%;
height: 35px;
}
.page { overflow:auto; width: 90%; height: 100%; }
.containerMap { width:100%; background: grey; }
.error-content{
width: 80wh;
height: 300px;
overflow: auto;
align-items: center;
}
/*************/
.board­__sprint {
/*background: #5ba4cf;*/
position: absolute;
left: auto;
padding: 20px;
overflow-x: auto;
white-space: nowrap;
}
.list {
display: inline-block;
vertical-align: top;
/*background: #d2d7e5;*/
width: 300px;
padding: 1px;
}
.list-content {
max-height: 80%;
overflow-y: auto;
padding-right: 5px;
/*margin-right: -5px;*/
margin-bottom: 20px;
padding-bottom: 60px;
}
.list-name {
padding: 10px;
border: none;
background: transparent;
}
.add-ticket {
background: linear-gradient(to bottom, #61bd4f 0, #5aac44
100%);
color: white;
font-weight: bold;
border: none;
padding: 10px;
}
.ticket {
/*background: white;*/
flex: 0 0 auto;
margin: 5px;
width: 200px;
height: 70px;
align-items: center;
white-space: normal;
}
.ticket-title {
width: 100%;
padding: 20px;
}
/*********/
</style>
<iron-ajax
id="getEpicSprintMap"
method="GET"
url="{{url}}"
handle-as="json"
content-type="application/json"
on-response="handleResponseGetEpicSprintMap"
on-error="handleErrorGetEpicSprintMap"
last-response="{{mapsData}}"
last-error="{{lastError}}">
</iron-ajax>
<div style="width: 100%">
<div style="float:left;">
<div><h5></h5></div>
<paper-icon-button src="../images/icons/help-icon-png.png"
on-tap="showHelpDialog"></paper-icon-button>
</div>
<div style="float:right;">
<div><h5></h5></div>
<paper-icon-button src="../images/icons/support-icon-png.png"
on-tap="showHelpDialog"></paper-icon-button>
</div>
</div>
<template is="dom-if" if="[[signedin]]">
<template is="dom-if" if="[[mapsData.successFlag]]">
<div style="float: center;">
<h5 style="color: white; font-size: 12px; text-
align:left;"> </h5>
</div>
<div style="float: center; display: flex">
<iron-image src="../images/logo.png" preload
sizing="contain"
on-tap="reloadEpics" style="width:200px; height:200px;
margin:auto;" ></iron-image>
</div>
<div style="float: center;">
<h1 style="color: white" class="launchAmount">Epics &
Sprints</h1>
<h2 style="color: white" class="launchAmount">Number of
sprints that an Epic spans</h2>
</div>
<input id="test" min="1" max="1000" value='1000' step="1"
onchange="showVal(this.value)" type="range"/>
<div class="containerMap" id="someid">
<div class="page">
<div class="content">
<div class="board­__sprint">
<template is="dom-repeat" items="{{mapsData.data}}"
as="row">
<div class="list">
<div class="list­-content">
<div style="text-align: center;">
<iron-image class=""
src="../images/icons/epic-icon-png.png"
preload
sizing="contain"
style="width:50px; height:50px; margin-
left: 50px;" ></iron-image>
</div>
<div style="text-align: center;">
<h3 class="sprintTitle" style="color: white; font-
size: 15px;background: black; padding: 10px; margin-top: 5px;">
<b>Epic: </b>[[row.key]]
</h3>
<h3 class="sprintTitle" style="color: white; font-
size: 15px;background: black; padding: 10px; margin-top: 5px;">
[[row.title]]
</h3>
</div>
<template is="dom-repeat" items="{{row.sprint}}"
as="sprint">
<div class="ticket">
<paper-card style="float:center; width: 95%"
class$="{{_computedCardColorStories()}}">
<div style="width: 100%;">
<div style="float:left; width: 10%"
style$="{{getRandomInt(0, 20)}}">
<h7> </h7>
</div>
<div style="float:left; width: 90%; text-
align: center; padding: 10px;">
<h7 style="color: black; font-size:
18px; text-align:center;">[[sprint]]</h7>
</div>
</div>
</paper-card>
</div>
</template>
</div>
</div>
</template>
</div>
</div>
</div>
</div>
</template>
</template>
</template>
</template>
<script>
/**
* #polymer
* #extends HTMLElement
*/
class EpicSprintMapPage extends Polymer.Element {
static get is() { return 'epicsprint-page'; }
constructor() {
super();
}
ready() {
super.ready();
}
static get properties() {
return {
user: { type: Object, notify: true, readOnly: false, observer: '_userChanged' },
signedin: { type: Boolean, notify: true, readOnly: false, observer: '_signedinChanged' },
statusKnown: { type: Boolean, notify: true, readOnly: false, observer: '_statusChanged' },
localSettings : { type: Object, notify: true, readOnly: false },
mapsData: { type: Object, notify: true },
filterFromDate : { type: String, notify: true },
filterToDate: { type: String, notify: true },
defaultSprintVelocity: { type: Number, value: 0, notify: true },
zoomVal: { type: Number, value: 100, notify: true },
}
};
_userChanged(user){
this.user = user;
}
_signedinChanged(signedin){
this.signedin = signedin;
}
_statusChanged(statusKnown){
this.statusKnown = statusKnown;
}
showVal()
{
var zoomScale = Number(this.zoomVal)/100;
console.log('zoomScale = '+zoomScale);
var ele = document.getElementsByClassName('containerMap')[0]; // returns null in console can't find the element in shadow Dom
var el = this.shadowRoot.querySelector('someid'); // returns null in console also tried '#someid' still null
console.log('shadowRoot el = '+JSON.stringify(el));
var elx = document.getElementById('someid'); // returns null in console
console.log('shadowRoot el = '+JSON.stringify(elx));
//var el = this.$.someid; // doesn't find the element
// tried this.$['#someid'] this.$$('#someid')
console.log(el);
transformOrigin = [0,0];
el = el || instance.getContainer();
var p = ["webkit", "moz", "ms", "o"],
s = "scale(" + zoomScale + ")",
oString = (transformOrigin[0] * 100) + "% " + (transformOrigin[1] * 100) + "%";
for (var i = 0; i < p.length; i++) {
el.style[p[i] + "Transform"] = s;
el.style[p[i] + "TransformOrigin"] = oString;
}
el.style["transform"] = s;
el.style["transformOrigin"] = oString;
}
}//end Polymer
window.customElements.define(EpicSprintMapPage.is, EpicSprintMapPage);
</script>
</dom-module>
I am expecting I can find the element in shadow dom and be able to style the element and mimick zoom in out functionality by transforming the div.
I am not sure how to get the element and what syntax it should be.
Try to remove :
<template is="dom-bind">
...
</template>
You can use dom-bind template in index.html in order to binding without to defining new custome element. Then you can select your div element with this.shadowRoot...
For more information about dom-bind
EDİT
As there is some variable which I don't know the values, But keep in your mind that if dom-if statement is false then its content does not render. So, you can not access any element inside.

set text inside a check box

Hi is it possible to add text inside check box replacing the tick icon.
I am could not achieve it with this code could someone suggest me how to make a size selection box with a text inside it
<ion-col>
<p>Choose the size</p>
<ion-item>
<ion-checkbox >S</ion-checkbox>
</ion-item>
</ion-col>
Help me to bring out this type of UI
You can hide the input and use the label to select the checkbox. Then style your label like in the example below, using :not(:checked) and :checked selectors. Same logic can be applied to radio buttons.
ul {
padding: 0;
margin: 0;
clear: both;
}
li{
list-style-type: none;
list-style-position: outside;
padding: 10px;
float: left;
}
input[type="checkbox"]:not(:checked),
input[type="checkbox"]:checked {
position: absolute;
left: -9999%;
}
input[type="checkbox"] + label {
display: inline-block;
padding: 10px;
cursor: pointer;
border: 1px solid black;
color: black;
background-color: white;
margin-bottom: 10px;
}
input[type="checkbox"]:checked + label {
border: 1px solid white;
color: white;
background-color: black;
}
<ul>
<li>
<input type="checkbox" id="check_1" name="check_1" value="check_1">
<label for="check_1">S</label>
</li>
<li>
<input type="checkbox" id="check_2" name="check_2" value="check_2">
<label for="check_2">M</label>
</li>
<li>
<input type="checkbox" id="check_3" name="check_3" value="check_3">
<label for="check_3">L</label>
</li>
<li>
<input type="checkbox" id="check_4" name="check_4" value="check_4">
<label for="check_4">XL</label>
</li>
</ul>
Updated
check updated demo here
Add the following Js to get the relevant radio value
JS:
$("body").on("click", "label", function(e) {
var getValue = $(this).attr("for");
var goToParent = $(this).parents(".select-size");
var getInputRadio = goToParent.find("input[id = " + getValue + "]");
console.log(getInputRadio.attr("id"));
});
I assume that the user select only one size at a time. if user can select the multiple size modify the example with checkbox.
Try this
Check Demo here
HTML:
<div class="select-size">
<input type="radio" name="s-size" id="small" checked/>
<input type="radio" name="s-size" id="medium" />
<input type="radio" name="s-size" id="large" />
<input type="radio" name="s-size" id="x-large" />
<input type="radio" name="s-size" id="xx-large" />
<label for="small">S</label>
<label for="medium">M</label>
<label for="large">L</label>
<label for="x-large">XL</label>
<label for="xx-large">XXL</label>
</div>
CSS:
.select-size input{
display: none;
}
label {
display: inline-block;
width: 50px;
height: 50px;
text-align: center;
border: 1px solid #ddd;
line-height: 50px;
cursor: pointer
}
#small:checked ~ label[for="small"],
#medium:checked ~ label[for="medium"],
#large:checked ~ label[for="large"],
#x-large:checked ~ label[for="x-large"],
#xx-large:checked ~ label[for="xx-large"] {
background: #999;
color: #ffffff;
}

How do I position a radio button correctly?

http://jsfiddle.net/BD8j2/
I am trying to put a radio button to the right of the arrow picture, but it always keeps going someplace else for some reason. I want it between the arrow and the word Masculino.
I also don't want this button to really record anything, it's just there for aesthetic purposes. But I want when someone click on this box for the radio button to fill and then to link to another page.
Is this possible to do? For the whole box to be the link? I was thinking of wrappign the whole div in a <a href> which I think would work.
Try this: http://jsfiddle.net/BD8j2/8/.
(The HTML in the first version of this post is invalid (input inside a), and it is not cross-browser compatible, so I have replaced it with a JavaScript example.)
HTML:
<div class="answers">
<form>
<label class="links">
<input type="radio" name="sex" value="male" />
Masculino
</label>
</form>
</div>
<div class="answers">
<form>
<label class="links">
<input type="radio" name="sex" value="female" />
Femenino
</label>
</form>
</div>
JavaScript:
function init() {
var link_elems = getElementsByClass('links');
for(var i = 0; i < link_elems.length; i++) {
addEvent(link_elems[i], 'click', goToLink);
}
}
function goToLink(e) {
if(e.stopPropagation) {
e.stopPropagation();
} else if(typeof e.cancelBubble != 'undefined') {
e.cancelBubble();
}
e.currentTarget.children[0].checked = true;
window.location = e.currentTarget.children[1].href;
}
function addEvent(elem, event, handler) {
if(elem.addEventListener) {
elem.addEventListener(event, handler, false);
} else if(elem.attachEvent) {
elem.attachEvent('on' + event, handler);
} else {
elem['on' + event] = handler;
}
}
function getElementsByClass(className) {
if(document.getElementsByClassName) {
return document.getElementsByClassName(className);
} else if(document.all) {
var everything = document.all;
var all_length = everything.length;
var matches = [];
for (var i = 0; i < all_length; i++) {
if(everything[i].className == className) {
matches[matches.length] = everything[i];
}
}
return matches;
}
return false;
}
addEvent(window, 'load', init);
CSS:
.answers {
width: 220px;
height: 50px;
margin-top: 20px;
border-top: 1px solid black;
border-bottom: 1px solid black;
background-color: #ddd;
background-image: url('http://fortmovies.com/brazil/arrow.png');
background-repeat: no-repeat;
background-position: 0 50%;
}
.answers label {
float: left;
margin-left: 75px;
padding-top: 15px;
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
font-weight: bold
}
.answers input {
margin-right: 5px
}
In the previous version, the JavaScript required putting the link names and targets in two arrays, now I have made it automatic.
Something like http://jsfiddle.net/XEk5d/2/, the clicking part to go to another page would require JavaScript.
CSS
#answers {
width:220px;
height:50px;
background-color:#DDDDDD;
border-top:1px solid black;
border-bottom:1px solid black;
margin-top:20px;
}
#arrowcenter {
width:71px;
height:31px;
background-image:url('http://fortmovies.com/brazil/arrow.png');
background-position:0 50%;
background-repeat:no-repeat;
height:100%;
display:inline-block;
vertical-align:middle;
}
#answerstext {
background-position:0 50%;
display:inline-block;
vertical-align:middle;
}
form{
display:inline-block;
}
input{
vertical-align:middle;
}
HTML
<div id="answers">
<div id="arrowcenter"></div>
<form>
<input type="radio" name="sex" value="male" />
<div id="answerstext">Masculino</div>
</form>
</div><!-- end grayAnswer -->?

How to align this div contents properly?

Here is my layout,
Summary view http://img689.imageshack.us/img689/2500/yuidtsum.jpg
I am using one div and many spans for getting the above view... Look at all the rows ther are not properly aligned...
<div class="resultsdiv"><br />
<span style="width:200px;" class="resultName">' + employee.Emp_Name + '</span>
<span class="resultfields" style="padding-left:100px;">Category :</span>
<span class="resultfieldvalues">' + employee.Desig_Name + '</span><br /><br />
<span id="SalaryBasis" class="resultfields">Salary Basis :</span> <span class="resultfieldvalues">' + employee.SalaryBasis + '</span>
<span class="resultfields" style="padding-left:25px;">Salary :</span> <span class="resultfieldvalues">' + employee.FixedSalary + '</span>
<span style="font-size:110%;font-weight:bolder;padding-left:25px;">Address :</span>
<span class="resultfieldvalues">' + employee.Address + '</span>
</div>
and my css are
.resultsdiv
{
background-color: #FFF;border-top:solid 1px #ddd; height:50px; border-bottom:solid 1px #ddd; padding-bottom:15px; width:450px;
}
.resultseven { background-color: #EFF1f1; }
.resultshover { background-color: #F4F2F2; cursor:pointer; }
.resultName
{
font-size:125%;font-weight:bolder;color:#476275;font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif;
}
.resultfields
{
font-size:110%;font-weight:bolder;font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif;
}
.resultfieldvalues
{
color:#476275;font-size:110%;font-weight:bold;font-family:Arial,Liberation Sans,DejaVu Sans,sans-serif;
}
Any suggestion to get it aligned properly.... Should i use divs insted of spans to get this
properly aligned...
In my opinion, that is the type of data that should be in a table. It's not layout, it's tabular, repeating data.
Here is a rough cut of some rewritten HTML and CSS. I have not tested this, but it should get you close. Post a screenshot if it doesn't work.
HTML
<div class="resultsdiv">
<div class="name">' + employee.Emp_Name + '</div>
<div class="category"><span>Category :</span> ' + employee.Desig_Name + '</div>
<div class="salary_basis"><span>Salary Basis :</span> ' + employee.SalaryBasis + '</div>
<div class="salary"><span>Salary :</span> ' + employee.FixedSalary + '</div>
<div class="address"><span>Address :</span> ' + employee.Address + '</div>
</div>
CSS
.resultsdiv { color: black }
.resultsdiv span { color: #666 }
.resultsdiv { width: 600px}
.resultsdiv div { float: left }
.resultsdiv .name { width: 230px; padding-right 20px; }
.resultsdiv .category { width: 350px }
.resultsdiv .salary_basis { clear: left; width: 180px; padding-right: 20px }
.resultsdiv .salary { width: 180px; padding-right: 20px }
.resultsdiv .address { width: 200px; }

Resources