How to fix maximum width of a div? If contents of that div's exceeds than maximum width, we get scroller?
Tags: html,css
Problem :
I have #maindiv and i am putting divs in that programmatically. So i never know how much inner div will be inside #maindiv. every inner div has width: 160px. I used this css for #maindiv:
#maindiv
{
overflow: auto;
width: 640px;
height: 65px;
background:lightblue;
}
I want #maindiv to make horizontal scroller when total of innerdivs width is more than 160px. My css is not giving me right results. I am not getting any horizontal scroller even i fixed the width of the div. If i have innerdivs with more width that #maindiv then they make #maindiv wider. I even used max-width:160px for #maindiv as well. any Idea? Thanks in advance.
Solution :
You could try using
overflow-y: scroll;
See http://jsfiddle.net/4CCfy/
CSS Howto..
If you want to place an element above all other elements at a specific position, you should move it out of all the other elements so it is a direct...
Server Sent Events Tutorial Server-Sent Events - One Way Messaging A server-sent event is when a web page automatically gets updates from a server. This was also possible before, but...
$(function(){ $('.send_email > a').click(function(){ $('.send_email').hide(); $('.email_sent').show(); }); }); .email_sent { display: none; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="send_email"> <a...
Try using Descendant Selectors: a img { border-bottom: none; } If it doesn't seem to be working, first make sure that the selector is correct (i.e. is referencing the correct...
You can use this, it will definitely work as you requested. img { border: 13px solid blue; border-radius: 10px; } ...
Seahorsepip's answer is fantastic. I made a lot of improvements on the non-fallback answer. http://jsfiddle.net/w1Lh4w2t/ I would recommend not doing that strange hidden png thing, when an Image object works...
To avoid too many comments to the general question as this should better be avoided on SO just the mentioned approach as answer. Just adjusted the Fiddle to this as...
The simplest means of achieving this, given the current approach, is to convert the HTML of the <td> opening tags from: "<tr><td>" to: "<tr><td class='example'>" And then use CSS to...
I think that using flexbox would be the best thing; if you want support for lesser browsers, you could do something like this: #content{background:green;width:100%;} #sidebar-right, #sidebar-left{ background:pink; width:50%;float:left; } @media...
I have done something similar before. What you can do is load the next item behind the current one with visibility:hidden; and possibly a lesser z-index. This means the shape...
Ok i've changed the following attributes under #form and it worked: #form { padding: 35px; width: auto; margin: 25px 0; } #form p { float: none; /*or remove float line...
<edit> to get li active overflowing over top of its parent, you need to set negative margins too : DEMO updated CSS from original answer (at bottom): .menu-holder{ height: 30px;...
Select the relevant element #test3:hover ~ span{ background: red; } Demo Or else you can also use this #test3:hover ~ span.testspan1, #test3:hover ~ span.testspan2 { background: red; } Demo 2...
It's just as you said. You need to have one image with float:left and another with float:right. If both are placed before the text, they will each be at their...
$('.test:not(:has(h1))').css('font-size', '30px'); .test { font-size: 20px; color: #000; } <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div class="test"> <h1>This is a test</h1> <p>Welcome to the test</p> </div> <div...
This finds all elements with text-align: justify and sets the border to red. It should be plenty to get you started. Note: This is not very efficient, but there's not...
Use this code.. HTML <span class="mac"> <span class="screen"> <img src="http://th06.deviantart.net/fs71/PRE/i/2011/133/a/0/mac_desktop_xd_screenshot___by_ferxho0-d3g8qer.png"/> </span> </span> CSS span.mac{ width:450px; height:371px; display:inline-block;...
You can do this with a semi transparent background color: http://jsfiddle.net/alessandro_pezzato/LWh75/ background: rgba(0,0,0,0.8); ...
Background images in CSS 2.1 cannot be resized, although CSS 3 supports the background-size property it's not widely implemented. background-size: 10px 10px; The obvious alternative is to just use an...
.nb_item { display:inline-block; width:auto; padding:0px 10px; color:#FFFFFF; margin:auto; text-align:center; } Instead of giving a width of 12.5%, give the width:auto, and then add a padding. and as far as cramping...
Grids elements of Semantic UI got display: inline-block, so you can set white-space:nowrap to prevent that elements wrap in a row: <div class="features ui grid noMargin" style="overflow-y:auto;white-space:nowrap;"> <div class="four wide...
Apply img this css property: img { display: block; } Instead of giving to the tag, add a class to those img elements. that would be better. Working Fiddle...
The problem is your line-height rule for #menus ul li a which targets links in drop down too. So 45px line-height in a 26px height parent can't be rendered fine....
You need a more specific selector. Change the selector on your second rule to: #main .page-header h1 Compare the specificity values for each selector: #main h1 0101 .page-header h1 0011...
I haven't tested this css, but I think it'll do what you want: html { width: 100%; height: 100%; } body { position: relative; width: 100%; height: 100%; } #footer...
Here's a good tutorial on how to make a CSS drop down/expanding menu http://webdesignerwall.com/tutorials/css3-dropdown-menu...
Element.Styles.textShadow = "rgb(@, @, @) @px @px @px"; then just use like this.tween('text-shadow', '#000 10px 10px 30px'); - but you need to define a base shadow first VIA MOOTOOLS. this...
The way you have it, you will select div.header #id instead of div.header#id. You can fix that with a parent selector (&): div.header { &#id { position: relative; } border:...
Assuming you varaible is valid and holds something like "#f90", then you can do: style="color:<?= $values['color']; ?>;" or style="color:<?php echo $values['color']; ?>;" if you view/template is a .php then this...
Remove the padding, and replace with position:absolute; top:70%; ...