Same DIV twice different floats? - class

I'm trying to clean up my code a bit by not having so many div id's. As I understand you're not supposed to use the same div id more than once.
The HTML:
<div id="sides" class="alignLeft"></div>
<div id="sides" class="alignRight"></div>
<div id="center"></div><!--center-->
The CSS:
.alignLeft {
float: left;
}
.alignRight {
float: right;
}
#sides {
width: 350px;
height: 45px;
}
#center {
width: 350px;
height:350px;
}
As you can see I have used the #sides div twice in the html but applied different float classes (left, right). Even though the code seems to work, I know it's incorrect. What would be the correct way to use the same div with different floats?

Yes id selectors are meant to be used only once per page. You could refactor your code to look like this.
HTML
<div class="sides alignLeft"></div>
<div class="sides alignRight"></div>
<div id="center"></div><!--center-->
CSS
.alignLeft {
float: left;
}
.alignRight {
float: right;
{
.sides {
width: 350px;
height: 45px;
}
#center {
width: 350px;
height:350px;
}

You can assign multiple classes to one element, so you can use sides as a class instead of an id:
The HTML:
<div class="sides alignLeft"></div>
<div class="sides alignRight"></div>
<div id="center"></div><!--center-->
The CSS:
.alignLeft {
float: left;
{
.alignRight {
float: right;
{
.sides {
width: 350px;
height: 45px;
}
#center {
width: 350px;
height:350px;
{

Related

What character can I use to display the "four arrows icon"?

What Unicode character can I use do display this character?
I currently need it to write a .doc document, but I would like to know if a Unicode character is available, in order to print it out in an app, or if some font has this glyph in it.
These glyphs:
✥ FOUR CLUB-SPOKED ASTERISK
✢ FOUR TEARDROP-SPOKED ASTERISK
✣ FOUR BALLOON-SPOKED ASTERISK
are the best matches. If used with little font sizes, they can do the job.
An ugly alternative would be using three glyphs, maybe mixing different font sizes and faces: ←↕→
UPDATE:
A (great) alternative exists for HTML. The trick is placing two characters with absolute positioning, one over the other:
UPDATE2: added another variant of the "rotated" four-arrows, using triangle-headed arrows
.container {
width: 100px;
height: 100px;
position: relative;
}
.first,
.second,
.third,
.fourth {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.second {
z-index: 10;
}
.third {
z-index: 20;
}
.fourth {
z-index: 30;
}
body {
font-family: Monospace; font-size: 50px;
}
<div class="container">
<div class="first">↔</div>
<div class="second">↕</div>
</div>
<div class="container">
<div class="first">⤨</div>
<div class="second">⤪</div>
</div>
<div class="container">
<div class="first">⭦</div>
<div class="second">⭧</div>
<div class="third">⭨</div>
<div class="fourth">⭩</div>
</div>

Created a custom xtype component in one app, trying to copy it to different app not working unless I have the original app in AEM CD5

I have created Multifield dialog i AEM 5.6.1 and wold like to know How do I make an AEM CQ5 component responsive? fit to different devices/screens based on users viewpoint??
Better way for responsive design is CSS3 #media Rule.
In the following snippet menu for devices with width < 500 will be 100% width of screen:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<style>
body {
font-family: "Lucida Sans", Verdana, sans-serif;
}
.main img {
width: 100%;
}
h1{
font-size: 1.625em;
}
h2{
font-size: 1.375em;
}
.header {
padding: 1.0121457489878542510121457489879%;
background-color: #f1f1f1;
border: 1px solid #e9e9e9;
}
.menuitem {
margin: 4.310344827586206896551724137931%;
margin-left: 0;
margin-top: 0;
padding: 4.310344827586206896551724137931%;
border-bottom: 1px solid #e9e9e9;
cursor: pointer;
}
.main {
padding: 2.0661157024793388429752066115702%;
}
.right {
padding: 4.310344827586206896551724137931%;
background-color: #CDF0F6;
}
.footer {
padding: 1.0121457489878542510121457489879%;
text-align: center;
background-color: #f1f1f1;
border: 1px solid #e9e9e9;
font-size: 0.625em;
}
.gridcontainer {
width: 100%;
}
.gridwrapper {
overflow: hidden;
}
.gridbox {
margin-bottom: 2.0242914979757085020242914979757%;
margin-right: 2.0242914979757085020242914979757%;
float: left;
}
.gridheader {
width: 100%;
}
.gridmenu {
width: 23.481781376518218623481781376518%;
}
.gridmain {
width: 48.987854251012145748987854251012%;
}
.gridright {
width: 23.481781376518218623481781376518%;
margin-right: 0;
}
.gridfooter {
width: 100%;
margin-bottom: 0;
}
#media only screen and (max-width: 500px) {
.gridmenu {
width: 100%;
}
.menuitem {
margin: 1.0121457489878542510121457489879%;
padding: 1.0121457489878542510121457489879%;
}
.gridmain {
width: 100%;
}
.main {
padding: 1.0121457489878542510121457489879%;
}
.gridright {
width: 100%;
}
.right {
padding: 1.0121457489878542510121457489879%;
}
.gridbox {
margin-right: 0;
float: left;
}
}
</style>
</head>
<body>
<div class="gridcontainer">
<div class="gridwrapper">
<div class="gridbox gridheader">
<div class="header">
<h1>The Pulpit Rock</h1>
</div>
</div>
<div class="gridbox gridmenu">
<div class="menuitem">The Drive</div>
<div class="menuitem">The Walk</div>
<div class="menuitem">The Return</div>
<div class="menuitem">The End</div>
</div>
<div class="gridbox gridmain">
<div class="main">
<h1>The Walk</h1>
<p>The walk to the Pulpit Rock will take you approximately two hours, give or take an hour depending on the weather conditions and your physical shape.</p>
<img src="http://www.w3schools.com/cssref/pulpitrock.jpg" alt="Pulpit rock" width="" height="">
</div>
</div>
<div class="gridbox gridright">
<div class="right">
<h2>What?</h2>
<p>The Pulpit Rock is a part of a mountain that looks like a pulpit.</p>
<h2>Where?</h2>
<p>The Pulpit Rock is in Norway</p>
<h2>Price?</h2>
<p>The walk is free!</p>
</div>
</div>
<div class="gridbox gridfooter">
<div class="footer">
<p>This web page is a part of a demonstration of fluid web design made by www.w3schools.com. Resize the browser window to see the content response to the resizing.</p>
</div>
</div>
</div>
</div>
</body>
</html>
See more in fo in the following page

Fancybox not stretching when using to display form

I want to display a simple form inside fancybox overlay, which also works nice on smaller screen. i've set up an example on here http://design.imago.ee/test/fancybox-form/index1.html
Initially i set the form width to be 450px, at 620px screen size im setting the form width to 100% and after i have done it, fancybox window collapses width wise and the form is not displayed properly. Interestingly that doesnt happen with regular text content (second button in the example). I know that i could just change the width manually with media queries, but it isnt really a good solution. Can anyone help? Thank you.
It's not very elegant solution but will give you an idea and porbably put you closer to your goal
Change in fancybox css
.fancybox-inner {
overflow: hidden !important;
}
Script
Calculate width of window and adjust the width of content, use setInterval so any change in width will be adjusted dynamically.
setInterval(dimension, 100);
function dimension() {
$('.content').css('width', $(window).width() * 0.6);
}
Demo
$(document).ready(function () {
$('.fancybox').fancybox({
padding: 0,
helpers: {
overlay: {
locked: false
},
title: {
type: 'inside'
}
}
});
setInterval(dimension, 100);
function dimension() {
$('.content').css('width', $(window).width() * 0.6);
}
});
.fancybox-inner {
overflow: hidden !important;
}
* {
margin: 0;
padding: 0;
}
/* =========================== Layout styles =================== */
body, html {
height: 100%;
}
body {
font: 14px/1.4'Open sans', sans-serif;
overflow: hidden;
background-color: #fff;
padding: 20px 4%;
}
.centered-wrap {
max-width: 1100px;
margin: 0 auto;
width: 100%;
}
a.fancybox {
display: inline-block;
vertical-align: top;
background-color: #59a3d3;
color: #fff;
padding: 4px 7px;
border-radius: 2px;
text-decoration: none;
}
h1 {
font-size: 23px;
font-weight: 600;
margin-bottom: 15px;
}
p {
margin-bottom: 20px;
}
.content {
padding: 20px 30px;
}
input[type="text"] {
border: 1px solid #ccc;
height: 30px;
font: 13px/30px'Open sans', sans-serif;
box-sizing: border-box;
width: 100%;
padding: 0 7px;
}
#form {
width: 450px;
padding: 30px;
}
#form .row {
margin-bottom: 10px;
}
#form .col {
float: left;
}
#form .col1 {
width: 25%;
}
#form .col2 {
width: 75%;
}
#form label {
display: inline-block;
vertical-align: top;
padding: 6px 10px 0 0;
}
/* ======================= media queries ======================= */
#media screen and (max-width: 620px) {
#form {
width: 100%;
text-align: center;
padding: 5px;
}
#form .col {
float: none;
width: auto;
text-align: center;
margin-right: 10px
}
#form label {
}
}
/* ======================== clearfix =========================== */
/* Force Element To Self-Clear its Children */
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content:" ";
clear: both;
height: 0;
}
.clearfix {
display: inline-block;
}
/* start commented backslash hack \*/
* html .clearfix {
height: 1%;
}
.clearfix {
display: block;
}
/* close commented backslash hack */
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.css" />
<div class="centered-wrap">
<p><a class="fancybox" href="#form">Fancybox with form</a></p>
<div style="display: none;">
<div id="form" class="content">
<div class="row clearfix">
<div class="col col1">
<label>Form label</label>
</div>
<div class="col col2">
<input type="text">
</div>
</div>
<div class="row clearfix">
<div class="col col1">
<label>Form label</label>
</div>
<div class="col col2">
<input type="text">
</div>
</div>
<div class="row clearfix">
<div class="col col1">
<label>Form label</label>
</div>
<div class="col col2">
<input type="text">
</div>
</div>
</div>
</div>
</div>
Fiddle Example
Note: Adjust the fiddle view screen to see how form width adjust itself with the change of screen size.

change class attributes when hovering over other css class

I am trying to give a div with class "left2" a border-radius when class "left1_sub" is hovered.
I´ve searched a lot of solutions, but nothing seems to work for me.
The html to it: http://web318.login-11.hoststar.at/ben/kleinraum/wp/menuimg/index.html
and the full css: http://web318.login-11.hoststar.at/ben/kleinraum/wp/menuimg/style.css
.left1_sub{
padding-top:2%;
padding-bottom:2%;
width: 100%;
float: left;
background-color: #cccccc
}
.left1_sub:hover ~ .left2 {border-radius: 10px;}
.left2{
float: left;
margin-right: 20px;
margin-top: 20px;
width: 500px;
height:600px;
background-color: #ccccff
}
Just introducing myself to css3 so sorry if there are failures.
ben
This can be done very easily with jQuery or something similar.
If are comfortable using jQuery something like this would work.
First, create a class in CSS with a border radius:
.rounded { border-radius: 5px; /* (or whatever) */ }
Then, in <script> tags:
jQuery(document).ready(function($) {
var obj = $('.left1_sub'),
target = $('.left2');
obj.hover(
//mouse in
function(){
target.addClass('rounded');
//mouse out
},function(){
target.removeClass('rounded');
});
});
http://jsfiddle.net/wGzgB/11/

Class inside a Div, only working once

new to the forum, as this is the first time i haven't been able to use search to solve my issue, maybe its my wording.
I'm hoping one of you guys could help me.
I have a problem, i have written a class for my navbar, which i would like to apply to all links as well. I have a 3 column layout, all wrapped in a container (so i can have a sticky footer). the class in my header works, but for the life of me i cant figure out why it wont apply the the sidebar navigation. Each section of the page (header,col1,col2,col3 and the footer) has an ID, and inside which i have told it to apply my nav class, but to no avail.
Sorry if you don't get me, but any help would be much appreciated .
regards
Update...
It works here,
<div id="header">
</br>
<img src="images/banner.gif" href="index.html" width="60%"
alt="RedHotPolka">
<br/>
<div class="nav1">
Home
Shop
About
Contact
</div>
</div>
But not here...
<div id="rcol" align="right">
<div class="nav1">
<br/><br/><br/><br/>
What's hot?<br/><br/>
Sale<br/><br/>
</div>
</div>
the css im using..
.nav1
a:link {text-decoration:none; color:#000000; font-size:22px; padding:4px;}
a:visited {text-decoration:none; color:#000000;}
a:active {text-decoration:none; color:#ff0000;}
a:hover {text-decoration:none; color:#ff0000;}
And
*{margin:0;padding:0;}
html, body {height: 100%;}
#container
{
min-height: 80%;
overflow:auto;
margin-bottom: 100px;
}
#footer
{
position:relative;
margin-top: -100px;
height: 100px;
clear: both;
}
#header
{
margin-bottom: 10px
}
#lcol
{
float: left;
width: 20%;
margin-left: 0%;
display: inline;
}
#mcol
{
float: left;
width: 48%;
margin-left: 6%;
}
#rcol
{
float: right;
width: 20%;
margin-left: 6%;
}
Thanks