How can I make a div like this grow to the right instead of down? I want a constant height of my image list, and I want a scrollbar for horizontal scrolling as needed.
http://jsfiddle.net/8J2KM/
<div style="width:700px;height:130px;overflow-x:auto;">
<div style="height:130px;overflow:hidden;">
<a href="javascript:void();">
<div style="width:auto;height:100px;display:inline-block;margin-right:10px;color:#888;">
<img src="/cloudsign/web/images/layoutTemplate/8.png" alt="test1" style="border:solid 0px transparent;padding:9px 0px;width:130px;height:73px;" />
<br />test1
</div>
</a>
<a href="javascript:void();">
<div style="width:auto;height:100px;display:inline-block;margin-right:10px;color:#888;">
<img src="/cloudsign/web/images/layoutTemplate/9.png" alt="test1" style="border:solid 0px transparent;padding:9px 0px;width:130px;height:73px;" />
<br />test1
</div>
</a>
<a href="javascript:void();">
<div style="width:auto;height:100px;display:inline-block;margin-right:10px;color:#888;">
<img src="/cloudsign/web/images/layoutTemplate/10.png" alt="test1" style="border:solid 0px transparent;padding:9px 0px;width:130px;height:73px;" />
<br />test1
</div>
</a>
<a href="javascript:void();">
<div style="width:auto;height:100px;display:inline-block;margin-right:10px;color:#888;">
<img src="/cloudsign/web/images/layoutTemplate/11.png" alt="test1" style="border:solid 0px transparent;padding:9px 0px;width:130px;height:73px;" />
<br />
test1
</div>
</a>
<div style="width:auto;height:100px;display:inline-block;margin-right:10px;border:solid 3px transparent;padding:3px;color:black;font-weight:bold;">
<img src="/cloudsign/web/images/layoutTemplate/13.png" alt="test1" style="border:solid 3px black;padding:3px;width:130px;height:73px;" />
<br />
test1
</div>
<a href="javascript:void();">
<div style="width:auto;height:100px;display:inline-block;margin-right:10px;color:#888;">
<img src="/cloudsign/web/images/layoutTemplate/14.png" alt="test1" style="border:solid 0px transparent;padding:9px 0px;width:130px;height:73px;" />
<br />
test1
</div>
</a>
<a href="javascript:void();">
<div style="width:auto;height:100px;display:inline-block;margin-right:10px;color:#888;">
<img src="/cloudsign/web/images/layoutTemplate/15.png" alt="test1" style="border:solid 0px transparent;padding:9px 0px;width:130px;height:73px;" />
<br />
test1
</div>
</a>
</div>
</div>
</div>
You can either increase the size of the wrapping div to like 300% or how much u need or just add white-space:nowrap to the wrapping div and specify overflow-x:scroll for the inner wrapping div. You don't need overflow:auto in the outermost div.
So the first two divs :
<div style="width:700px;height:135px;white-space:nowrap">
<div style="height:135px;overflow-x:scroll;">
JSFiddle : http://jsfiddle.net/LnApB/
Also modify the height of these two divs to fit the height of the image+caption.
Of course as others have already pointed out tidy up your html, put your styles to separate style sheet to improve readability and maintainability.
Ok, lets tidy this up a little!
HTML:
<div id="container">
<a href="javascript:void();"> <!-- Have as many as you want. Copy -> paste. -->
<div class="block">
<img src="/cloudsign/web/images/layoutTemplate/15.png" alt="test1" />
<br />test1
</div>
</a>
</div>
CSS:
#container {
width: 100%;
overflow: auto;
height: 150px;
white-space:nowrap;
}
.block {
width:auto;
height:100px;
display:inline-block;
margin-right:10px;
color:#888;
}
img {
border:solid 0px transparent;
padding:9px 0px;
width:130px;
height:73px;
}
DEMO HERE
This includes a fix, take a look and work out were you went wrong. Please try to NOT put your CSS in with HTML. It will just make life harder for yourself, use classes .testClass or id's #testID
Hope this helps you.
In order to keep the item divs 'growing right', you need to define the width of the parent container to the largest width it will be inclusive of its contents (i.e. the total width of all child items).
There are a number of possible approaches, look at this fiddle for options.
As an aside, separating out your styles so they aren't inline is recommended, aside from leading to a far increased ability to maintain and control your code, it is much more efficient.
<div style="width:300px;overflow:auto;">
</div>
put your code inside this div
i updated jsfiddle here check it.
http://jsfiddle.net/8J2KM/2/
Remove <br/> in your html then it will grow horizontally.i have changed the js fiddle.Have a look.
DEMO HERE
Related
I am creating a small page using html which has a header and a body. The header is within a tag with blue background.
The problem I am facing is an image(android.png) which I want to be displayed in right end of the header seems getting placed below the header. How can I place the image in the right of the header.
I don't want to use CSS to align the image.
Click Run Code Snippet to view the current page layout
<html>
<body>
<div style="width:400px;height:60px;border:1px solid blue;background-color:#2196F3"">
<img align="left" width="80px" height="50px" src="http://icons.iconarchive.com/icons/igh0zt/ios7-style-metro-ui/512/MetroUI-Google-Gmail-icon.png">
<div text-align="left" style="font-size:20px;color:white"><h3>Something</h3></div>
<img align="right" width=150px height=50px src="http://www.sona-systems.com/img/android.png">
</div>
<div style="width:400px;height:400px;border:1px solid blue">
<p>
Hey,<br>
I am on vacation. I will respond after i come back</p>
<i><p>Sent from gmail</p></i>
</div>
</body>
</html>
I think this does what you're after. Your text div inside the header was filling out the rest of the width, pushing the second image to the next row:
<html>
<body>
<div style="width:400px;height:60px;border:1px solid blue;background-color:#2196F3">
<img style="float:left; width:80px;height:50px" src="http://icons.iconarchive.com/icons/igh0zt/ios7-style-metro-ui/512/MetroUI-Google-Gmail-icon.png">
<div style="font-size:20px;color:white; text-align:left; float:left">
<h3>Something</h3>
</div>
<img style="float:right; width:150px; heigh:50px; margin-top:5px; margin-right:5px" src="http://www.sona-systems.com/img/android.png">
</div>
<div style="width:400px;height:400px;border:1px solid blue">
<p>
Hey,
<br>I am on vacation. I will respond after i come back</p>
<i><p>Sent from gmail</p></i>
</div>
</body>
</html>
jsBin demo
Learn to use <style>. Makes life easier and more time to drink coffee with friends.
Float your image to the right
But also since H3 is a block element by default float it left (to remove the width)
<p> should not be enclosed in <i> since Paragraphs are block level elements and i are inline
<style>
.float-left{ float:left;}
.float-right{float:right;}
#header{
width:400px;
height:60px;
border:1px solid blue;
background-color:#2196F3;
}
#header img{
height:50px;
}
#header h3{
font-size:20px;
color:white;
}
#content{
width:400px;
height:400px;
border:1px solid blue;
}
</style>
HTML
<div id="header">
<img class="float-left" src="http://icons.iconarchive.com/icons/igh0zt/ios7-style-metro-ui/512/MetroUI-Google-Gmail-icon.png">
<h3 class="float-left">Something</h3>
<img class="float-right" src="http://www.sona-systems.com/img/android.png">
</div>
<div id="content">
<p>
Hey,<br>
I am on vacation. I will respond after i come back
</p>
<p><i>Sent from gmail</i></p>
</div>
Another solution would be to place your images right inside the H3 element
<h3><img> Some Text <img></h3>
but than you need to play with the H3's line-height and the image's vertical-align etc.
Since you want to avoid CSS, I'll assume this is for output to an HTML-handicapped email client such as Outlook.
You can do this without using CSS on your images by simply moving the second image before the first one within the HTML.
<html>
<body>
<div style="width:400px;height:60px;border:1px solid blue;background-color:#2196F3"">
<img align="right" width=150px height=50px src="http://www.sona-systems.com/img/android.png">
<img align="left" width="80px" height="50px" src="http://icons.iconarchive.com/icons/igh0zt/ios7-style-metro-ui/512/MetroUI-Google-Gmail-icon.png">
<div text-align="left" style="font-size:20px;color:white"><h3>Something</h3></div>
</div>
<div style="width:400px;height:400px;border:1px solid blue">
<p>
Hey,<br>
I am on vacation. I will respond after i come back</p>
<i><p>Sent from gmail</p></i>
</div>
</body>
</html>
I fixed this (it will still need some brushing up, but it works) by switching the position in the code where the <div> with "Something" in it and the messed up image are.
Instead of
<div text-align="left" style="font-size:20px;color:white;"<h3>Something</h3></div>
<img align="right" width=150px height=50px src="http://www.sona-systems.com/img/android.png">
Do
<img align="right" width="150px" height="50px" src="http://www.sona-systems.com/img/android.png"> <!--added in quotes for the width and height-->
<div text-align="left" style="font-size:20px;color:white;"<h3>Something</h3></div>
You also have some a wrong double quote in this line
I am attempting to place a shadow at the bottom of the .top_section of my code. However, I cannot make it work. I have two sections (a top and a bottom), the shadow needs to go bellow the .top_section
Here is the code:
CSS:
.top_section {
background-image: url(../images/background.png);
background-repeat: no-repeat;
}
#boxShadow{box-shadow: 10px 10pxrgba(0, 0, 0, .4);}
.bottom_section {
background-image: url(../images/background.png);
}
HTML:
<div class="container-fluid top_section">
<div id="boxShadow">
<section>
<div class="row-fluid">
<div class="span4 offset4">
<br />
<img src="images/logo.png" width="400" height="400" image alt="image" />
</div>
</div>
<div class="row12">
<h3><p class="text-center">ANIMATOR & DIGITAL ILLUSTRATOR</p></h3>
<h4><p class="text-center">I'M MARK FROM SINGAPORE, I DESIGN & MAKE THINGS MOVE. </p></h4>
<h4><p class="text-center">I AM CURRENTLY FREELANCING AND STUDYING AT ANIMATION MENTOR.</p></h4>
<br />
<br />
</div>
<div class="row-fluid">
<ul class="thumbnails">
<li class="span1 offset4">
<a href="#" class="thumbnail">
<img src="images/MAIL_icon.png" width="50" height="50" image alt="image" />
</a>
</li>
<li class="span1">
<a href="#" class="thumbnail">
<img src="images/DRIBBBLE_icon.png" width="50" height="50" image alt="image" />
</a>
</li>
<li class="span1">
<a href="#" class="thumbnail">
<img src="images/TWITTER_icon.png" width="50" height="50" image alt="image" />
</a>
</li>
<li class="span1">
<a href="#" class="thumbnail">
<img src="images/INSTAGRAM_icon.png" width="50" height="50" image alt="image" />
</a>
</li>
</ul>
</div>
</section>
</div>
</div>
Thank you for your help.
If I understand your question correctly, you can simply achieve it by setting the #boxShadow as:
#boxShadow {
box-shadow: 0px 10px rgba(0, 0, 0, .4);
}
You can take a reading of this for better understanding.
The only problem I see is with your code is just a typo in the boxShadow, otherwise it seems to work fine on this fiddle: typo fixed fiddle
Just needed a space between 10px and rgba.
#boxShadow { box-shadow: 0px 10px rgba(0, 0, 0, .4); }
Is this what you are looking for?
Edited to remove right-side shadow.
Here's a full tutorial of box-shadow, including cross-platform (and older browser) browser-specific prefixes: CSS3 Box Shadow Tutorial
You can try to modify this : http://jsfiddle.net/KyuH7/
<div id="box_wrapper">
<div id="box">
</div>
<div id="box_shadow">
</div>
</div>
#box_wrapper{
width:300px;
height:300px;
position:relative;
z-index:2;
}
#box_wrapper #box{
width:300px;
height:300px;
position:absolute;
background:#FFF;
top:0;
left:0;
z-index:3;
}
#box_wrapper #box_shadow{
width:290px;
height:50px;
background:#CCC;
position:absolute;
bottom:0;
left:5px;
z-index:0;
box-shadow:0px 10px 5px rgba(0,0,0,.1)
}
I have this html:
<div id='calendarControlPane'>
<div id='calendarControl'>
<div style="border-style:solid; display:inline-block;">
<div style="width:14;height:15;">
</div>
</div>
<div style="border-style:solid; display:inline-block;">
<div style="width:14;height:15;">
</div>
</div>
<div style="border-style:solid; display:inline-block;">
<div style="width:14;height:15;">
</div>
</div>
</div>
</div>
I'm using "display:inline-block" on container divs because I want those divs to fit the size of their contents.
The problem I have is that they are drawn next to each other and need to be drawn below each other.
Well, depending upon your actual final application, using a float can work (see fiddle), though older versions of IE can choke on it:
HTML
<div id="calendarControlPane">
<div id="calendarControl">
<div>
<div></div>
</div>
<div>
<div></div>
</div>
<div>
<div></div>
</div>
</div>
</div>
CSS
#calendarControl > div {
float: left;
clear: left;
border: 1px solid black;
}
#calendarControl > div > div {
width: 14px;
height: 15px;
}
Oldschool fix:
<div id='calendarControlPane'">
<div id='calendarControl'">
<div style="border-style:solid; display:inline-block;">
<div style="width:14;height:15;"></div>
</div><br />
<div style="border-style:solid; display:inline-block;">
<div style="width:14;height:15;"></div>
</div><br />
<div style="border-style:solid; display:inline-block;">
<div style="width:14;height:15;"></div>
</div>
</div>
</div>
Simply add a
<br />
after each div containing the inline-block class.
You're not really asking a question here, and the two bottom lines of your post are a bit hard to understand, but are you sure you don't want display: block instead?
edit: As drublic said, this is the default display value for divs, so you shouldn't need that style at all.
I have a list of icons to be displayed. I am using the following layout to do this:
<div class="icons">
<div class="icon1">
img src="someimage" <p>Some test </p>
</div>
.
.
.
</div>
This is the CSS I am using:
.icons{
margin-top:5px;
margin-left:5px;
left:0;
}
.icon1{
line-height:15px;
margin-top:8px;
width:75px;
}
How do I modify this so that if I add more divs with the class icon1 they will be aligned in a new column when the max-height is reached?
I am unsure whether float:left will work. In my experience this causes the div tags to be added side by side and once they reach the end of the parent div the next one will be added to the bottom of the first column. He requires the opposite #Jack
what i suggest is using jquery to check if the height of your div tags are exceeding the parent div. If they are then add a new div and begin appending your image-div tags to the new div with style="float:left". Thus if your initial DOM contains
< div class="icons" > < /div >
appending one element should change the DOM to
<div class="icons" >
<div class ="column" style="float:left">
<div class="icon1" > <img src="" height="" width="" /> </div>
</div>
</div>
appending another element should change it to
<div class="icons" >
<div class ="column" style="float:left">
<div class="icon1" > <img src="" height="" width="" /> </div>
<div class="icon2" > <img src="" height="" width="" /> </div>
</div>
</div>
appending a third element which exceeds the parent div would change the DOM to this
<div class="icons" >
<div class ="column" style="float:left">
<div class="icon1" > <img src="" height="" width="" /> </div>
<div class="icon2" > <img src="" height="" width="" /> </div>
</div>
<div class ="column" style="float:left">
<div class="icon3" > <img src="" height="" width="" /> </div>
</div>
</div>
You can do this with CSS 'multi-columns',
demo
but it is still a Candidate Recommendation, so the support is still very minimal even though you can use vendor prefixes to get it working(although not without some quirks) on the latest versions of Firefox, Chrome and Opera.
I have a divider that is centered in the page using margin:auto. Inside I have two more dividers (can't be combined, must be a divider nested in a divider) when I try to center something inside of this it does not center it in the center of the page. I'm assuming it has to do with the padding-left and padding-right that I've added...
Any insight?
Here's my code:
<center>
<div style="margin:auto; width:80%;">
<div style="width:50%; padding-left:20%; padding-right:20%;">
<div style="width:inherit; position:absolute; bottom:0%;">
<hr />
test
<hr />
<br><br><br>
</div>
</div>
</div>
</center>
Just remove the center tag:
<div style="margin:auto; width:80%;">
<div style="width:50%; padding-left:20%; padding-right:20%;">
<div style="width:inherit; position:absolute; bottom:0%;">
<hr />
test
<hr />
<br><br><br>
</div>
</div>
</div>
Check it out here: http://jsfiddle.net/V8qMm/