List doesn't display as grid with long texts - css

I'm having a problem sorting this out, basically it will be a list with icons and text below. Icon size remains the same but the text doesn't, as shown in the picture
.
The problem is when a <li> has a lot of text the rest float to the right of it. How can I sort this out.
My code is below:
ul.iconifier {
width: 100%;
list-style: none;
margin: 0 auto; padding: 0;
}
ul.iconifier li {
float: left;
margin: 10px; padding: 0;
text-align: center;
border: 1px solid #ccc;
width:8em;
height:200px;
-moz-border-radius: 3px; /*--CSS3 Rounded Corners--*/
-khtml-border-radius: 3px; /*--CSS3 Rounded Corners--*/
-webkit-border-radius: 3px; /*--CSS3 Rounded Corners--*/
display: block; /*--IE6 Fix--*/
height:101%;
}
ul.iconifier li a.thumb{
width: 128px;
height: 128px;
overflow: hidden;
display: block;
cursor: pointer;
}
ul.iconifier li a.thumb:hover {
}
ul.iconifier li p {
font: normal 0.75em Verdana, Arial, Helvetica, sans-serif;
margin: 0; padding: 10px 5px;
background: #f0f0f0;
border-top: 1px solid #fff; /*--Subtle bevel effect--*/
text-align:center;
width:118px;
}
ul.iconifier li a {text-decoration: none; color: #777; display: block;}
html:
<ul class="iconifier">
<li>
<img src="img/sprite.png" alt="Contacts" />
<p>English Depatment</p>
</li>
<li>
<img src="img/sprite.png" alt="Art" />
<p>Art Deptartment</p>
</li>
<li>
<img src="img/sprite.png" alt="Travel and Tourism" />
<p>Mathematics</p>
</li>
<li>
<img src="img/sprite.png" alt="Contacts" />
<p>Business Studies</p>
</li>
<li>
<img src="img/sprite.png" alt="Contacts" />
<p>English Depatment with a really long title that will hopefully fall</p>
</li>
<li>
<img src="img/sprite.png" alt="Art" />
<p>Art Deptartment</p>
</li>
<li>
<img src="img/sprite.png" alt="Travel and Tourism" />
<p>Mathematics</p>
</li>
<li>
<img src="img/sprite.png" alt="Contacts" />
<p>Business Studies</p>
</li>
<li>
<img src="img/sprite.png" alt="Contacts" />
<p>English Depatment</p>
</li>
<li>
<img src="img/sprite.png" alt="Art" />
<p>Art Deptartment</p>
</li>
</ul>

You need to use display: inline-block; instead of float to get them to push the row below them down for modern browsers. For IE6 & IE7 use display: inline.
Replace your ul.iconifier li with this code:
ul.iconifier li
{
margin: 10px;
padding: 0;
text-align: center;
border: 1px solid #ccc;
width: 8em;
-moz-border-radius: 3px; /*--CSS3 Rounded Corners--*/
-khtml-border-radius: 3px; /*--CSS3 Rounded Corners--*/
-webkit-border-radius: 3px; /*--CSS3 Rounded Corners--*/
display: -moz-inline-box; /* mozilla only */
display: inline-block; /* for browsers that support display:inline-block*/
vertical-align: top;
}
Then add this code to make IE6 & IE7 work:
/* Show only to IE7 */
*:first-child + html ul.iconifier li
{
display: inline;
}
/* Show only to IE6 */
* html ul.iconifier li
{
display: inline;
}
I learn this approach from these sites:
http://gtwebdev.com/workshop/layout/inline-block-gallery.php
http://www.css-lab.com/demos/image-display/inline-block-caption.html

there is two ways the first one is using css by make a fix height for the small blocks with trimmed text to fixed length
the second solution is using the server side development code by adding a clear style to the first LI on the line (note: this solution is for a fix no. of blocks at line)

Not ideal, but you could make the elements all the same size, that way you'd never have a problem of things being floated to the right.
Try adding this to your CSS:
ul.iconifier li
{
margin-bottom: -5000px;
padding-bottom: 5000px;
}
That CSS should make the elements the same height.
Cheers, Sean

Perhaps you can use http://plugins.jquery.com/project/gridLayout

Related

Images vertically stretched in Safari with parent container as display flex

I have a simple ul/li with images/text inside it. In Safari the images are getting vertically stretched:
HTML Code:
<ul class="dropdown-menu">
<li>
<a><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/31/Microsoft_Office_SharePoint_%282018%E2%80%93present%29.svg/1024px-Microsoft_Office_SharePoint_%282018%E2%80%93present%29.svg.png">SharePoint</a></li>
<li>
<a><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/31/Microsoft_Office_SharePoint_%282018%E2%80%93present%29.svg/1024px-Microsoft_Office_SharePoint_%282018%E2%80%93present%29.svg.png">SharePoint</a></li>
<li>
<a><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/31/Microsoft_Office_SharePoint_%282018%E2%80%93present%29.svg/1024px-Microsoft_Office_SharePoint_%282018%E2%80%93present%29.svg.png">SharePoint</a></li>
</ul>
CSS:
.dropdown-menu > li > a {
border-top: 0 solid #efefef;
color: inherit;
display: flex;
padding: 10px 30px 12px;
clear: both;
font-weight: normal;
line-height: 25px;
white-space: nowrap;
}
ul.dropdown-menu li a img {
width: 25px;
margin-right: 15px;
}
Safari:
Chrome:
Live fiddle URL to test:
https://jsfiddle.net/raghav_khunger/ko0wybhx/8/
I can add hardcoded height 25px to the image to overcome this issue:
ul.dropdown-menu li a img
One more solution could be having align-items: center; rule to .dropdown-menu > li > a (https://jsfiddle.net/raghav_khunger/ko0wybhx/10/)
Is there any other solution to it?
Are the above solutions valid for making the images do not stretch?
Can you share the reason why the images are getting stretched in the Safari whereas it is working fine in Chrome?
can you try with this code, hope it will work for you.
.dropdown-menu > li > a {
border-top: 0 solid #efefef;
color: inherit;
display: flex;
padding: 10px 30px 12px;
clear: both;
font-weight: normal;
line-height: 25px;
white-space: nowrap;
}
ul.dropdown-menu li a img {
width: 25px;
margin-right: 15px;
}
<ul class="dropdown-menu">
<li>
<a>
<div>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/31/Microsoft_Office_SharePoint_%282018%E2%80%93present%29.svg/1024px-Microsoft_Office_SharePoint_%282018%E2%80%93present%29.svg.png">SharePoint
</div>
</a></li>
<li>
<a>
<div>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/31/Microsoft_Office_SharePoint_%282018%E2%80%93present%29.svg/1024px-Microsoft_Office_SharePoint_%282018%E2%80%93present%29.svg.png">SharePoint
</div>
</a></li>
<li>
<a>
<div>
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/31/Microsoft_Office_SharePoint_%282018%E2%80%93present%29.svg/1024px-Microsoft_Office_SharePoint_%282018%E2%80%93present%29.svg.png">SharePoint
</div>
</a></li>
</ul>

Small Gap between my website content and other annoyances relating to gaps

I have a small gap between everything in my webpage and the browser's edge. I must have added some code that has done this, but am unsure what did. What do I do to remove this? Also in my navigation bar, the last link on the right hand side, has a small gap that is not highlighted on hover on the very edge on the right side of it.
I also need help with the gap between the navigation bar + header and the side banners. How do I remove that gap?
HTML:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Play - Learn - Grow</title>
<link rel="stylesheet" href="main.css">
</head>
<body class="body">
<span class="headers_t">
<span class="banner_h">
<img src="Images\Top_Banner_4.png" alt="Banner" height="150" width ="1240" />
</span>
<nav>
<ul class="nav">
<li>Home</li>
<li>About Us</li>
<li>Contact Us</li>
<li>Become a Member</li>
<li>Borrow Toys</li>
<li>Our Policies</li>
<li>Site Map</li>
</ul>
</nav>
</span>
<span class="banner_l">
<img src="Images\Side_Banner.jpg" alt="Banner" />
</span>
<span class="banner_r">
<img src="Images\Side_Banner.jpg" alt="Banner" />
</span>
<h2 class="headers">Welcome to the Home Page!</h2>
<div class="container">
Our aim is to provide the children of the community with an ever-changing variety of educational and fun toys to enhance
their cognitive, social, emotional and physical development in the important first six years of their lives.
<br><br><span class="Links">Be sure to check out our Wikispace site with more information here!</span>
</div>
<div id="content"></div>
<div id="footer">
Copyright &copy 2013
</div>
</body>
</html>
CSS:
/* Entire Document CSS */
html{
height: 100%;
}
/* Header CSS */
.headers_t{
/* Add something here */
}
.headers{
color: #FFD89A;
text-align: center;
padding: 10px;
}
/* Body CSS */
.body{
background-color: #61B329;
height: 50%;
color: #FFFFFF;
}
.container{
margin: 0 auto 0 auto;
width: 50em;
text-align: center;
padding-bottom: 500px;
height: 50%;
}
/* Navigation CSS */
.nav {
display: inline-block;
background-color: #00B2EE;
border: 1px solid #000000;
border-width: 1px 0px;
margin: 0;
padding: 0;
width: 100%;
}
.nav li {
list-style-type: none;
width: 14.28%;
float: left;
}
.nav a {
display: inline-block;
padding: 10px 0;
width: 100%;
text-align: center;
}
/* Banner / Picture CSS / Text in Images */
.banner_l{
float: left;
}
.banner_r{
float: right;
}
.banner_h, img{
display: block;
width: 100%;
}
/* Footer CSS */
#footer {
clear: both;
position: relative;
z-index: 10;
height: 3em;
margin-top: -3em;
}
#content {
padding-bottom: 3em;
}
/* Link CSS */
a:link{
color: #FFFFFF;
text-decoration: none;
}
a:visited{
color: #FFFFFF;
text-decoration: none;
}
a:hover{
background-color: #028482;
color: #FFFFFF;
text-decoration: underline;
}
a:active{
background-color: #FCDC3B;
color: #AA00FF;
text-decoration: overline;
}
.Links A:hover{
color: #028482;
background-color: transparent;
text-decoration: underline overline;
}
Disregard the .headers_t id in the css, which I am editing right now...unless that's the cause.
The JSFiddle link is here.
You need to add margin:0px and padding:0px to your body CSS
so:
.body{
background-color: #61B329;
height: 50%;
color: #FFFFFF;
margin:0px;
padding:0px;
}

HTML Get two divs to align side by side and not wrap when the browser is resized

I am using the below code and getting a problem where if I resize the browser my mainpage div wraps below the menubar div, I have tried min and max width and nothing has worked. Any help would be greatly appreciated. I want the mainpage div to not drop below the menubar and stay side by side with it even if the browser is made smaller.
HTML:
<div id="menubar" style="width: 16%; height: 100px;" title="menu" align = "center"> <!-- This is the code for the menubar, to add a new option to the menubar-->
<!-- Add a new <li> tag below the bottom link, to delete a link, delete the desired
link element. -->
<ul>
<li style="align: center;"><img alt="logo" height="63" src="images/ClevelandLogo.gif" width="126" /></li>
<li >Home</li>
<li>General</li>
<li>Site map</li>
<li>Rules & Procdures</li>
<li>Envirommental</li>
<li>Energy</li>
<li>IT</li>
<li>SAP</li>
<li>rhtrhtrh</li>
<li>Quality</li>
<li>Safety</li>
<li>Human resources</li>
<li>Production</li>
<li>Engineering</li>
<li>Feedback</li>
<li>wrefwefwefwef</li>
<li>Company mobile phones</li>
<li>Climate Survery Updates</li>
<li>Training</li>
<li>Sports Dome</li>
</ul>
</div>
<!--The mainpage div is where all the page's indivdual content is displayed.-->
<div id="mainpage" class="auto-style1" style="height: 486px; float:left; color: #000000; font-size: 11pt;">
<p> -0je45iwgtjj4eg0prjegtgfjotrsjgse'[agpraeogjk-odetkgbokporgkspfkdgkpfdgkpdfkg</p>
</div>
<!-- The container1 div is used to create the bottom green line in the site -->
CSS:
#mainpage
{
border: thin solid #008852;
width: 84%;
float: left;
background-color: #EDEFEE;
height: auto;
border-radius: 20px;
height: 100%;
position: fixed;
color: #008852;
}
#mainpage a:link, #mainpage a:visited
{
font-family: Arial, Helvetica, sans-serif;
font-size: small;
font-weight: bold;
}
#menubar ul
{
list-style-type: none;
margin: 0;
padding: 0;
float: left;
}
#menubar a:link, #menubar a:visited
{
border-top-width: 1px;
display: block;
font-weight: bold;
color: #000000;
background-color: #EFF1EB;
width: 180px;
text-align: center;
padding: 4px;
text-decoration: none;
text-transform: uppercase;
border-style: solid;
border-color: #638529;
font-family: Arial, Helvetica, sans-serif;
border: 1px;
position: fixed;
}
Wrap both of your div's in another element with a fixed width. Then float the menu bar and the main page to the left.
div {
width:50px;
height:50px;
border:1px solid black;
float:left;
}
section {
width:110px;
}
Something like the following: http://jsfiddle.net/uBgg3/
What you are trying to build can be done as follows.
<div id="menubar">
<div class="logo"><img alt="logo" src="http://placehold.it/126x63" /></div>
<ul>
<li>Home</li>
<li>General</li>
<li>Site map</li>
<li>Rules & Procdures</li>
<li>Envirommental</li>
<li>Energy</li>
<li>IT</li>
<li>SAP</li>
<li>rhtrhtrh</li>
<li>Quality</li>
<li>Safety</li>
<li>Human resources</li>
<li>Production</li>
<li>Engineering</li>
<li>Feedback</li>
<li>wrefwefwefwef</li>
<li>Company mobile phones</li>
<li>Climate Survery Updates</li>
<li>Training</li>
<li>Sports Dome</li>
</ul>
</div>
<div id="mainpage">
<p>Some sample text...</p>
</div>
and the CSS:
#menubar {
width: auto;
float: left;
margin-right: 20px;
}
#mainpage {
overflow: auto;
border: thin solid #008852;
background-color: #EDEFEE;
height: auto;
min-height: 500px;
border-radius: 20px;
color: #008852;
}
#mainpage a:link, #mainpage a:visited {
font-family: Arial, Helvetica, sans-serif;
font-size: small;
font-weight: bold;
}
#menubar ul {
list-style-type: none;
margin: 0;
padding: 0;
}
#menubar a:link, #menubar a:visited {
border-top-width: 1px;
display: block;
font-weight: bold;
color: #000000;
background-color: #EFF1EB;
width: auto;
text-align: center;
padding: 4px;
text-decoration: none;
text-transform: uppercase;
border-style: solid;
border-color: #638529;
font-family: Arial, Helvetica, sans-serif;
border: 1px;
}
See fiddle at: http://jsfiddle.net/audetwebdesign/sXNLT/
I cleaned up the inline styles since they were getting in the way. Use CSS rules, so much easier to maintain.
Float your #menubar to the left and set height:auto so that you can see all the links without any overflow issues.
On #mainpage, no need to float and set overflow: auto to prevent the content from wrapping around the floated menu.
Finally, no need for position: fixed in your navigation links.
You could put the two divs in a html table (2 columns, 1 row) and set the width of your body column to a specific value or percentage.

css border problem

How do i put a border on a div in css that doesn't have a set height?
Want to achieve this without using any javascript. Code is below.
HTML
<div id="main_container">
<div id="header">
<div id="topMenu">
<ul id="topNav">
<li>Home</li><li>Contact</li><li>Links</li>
</ul>
</div>
<div id="mainMenu">
<ul id="mainNav">
<li >Home</li><li >About Us</li><li >Multimedia</li><li >Multimedia</li><li >Multimedia</li><li >Multimedia</li><li >Multimedia</li><li >Multimedia</li>
</ul>
</div>
</div>
</div>
css
body{
text-align:center;
min-width:70%;
}
#main_container{
position:relative;
width:980px;
margin:auto;
text-align:center;
background-color:#FFFFFF;
border-color: #999999;
border-style: solid ;
border-width: 1px ;
margin-bottom: 20px;
}
#header{
position: relative;
width: 980px;
}
#mainMenu{
float:left;
width: 980px;
top: 50px;
background-color: #0099FF;
height: 30px;
}
#mainNav{
text-align: left;
}
ul#mainNav li{
display: inline;
margin: 0px 20px 0px 0px;
}
#topMenu{
width: 150px;
top: 10px;
text-align: right;
float:right;
margin-bottom: 20px;
}
ul#topNav li{
display: inline;
margin: 0px 10px 0px 0px;
}
#footer{}
Thanks in advance.
Does it work?
<div style="border:1px solid #000">
Your content here
</div>
It doesn't matter if there is no height attribute. Just use the border property as you normally would.
Edit: since you mention you have other divs inside your container div, I suspect you might need to use a clear. If you're still having issues with either the background or border not extending the length of the container, try adding this right before the closing div of the container:
<div style="clear:both"></div>
Just give the div some padding or content inside.
div {
border: solid 1px #000;
padding: 10px;
}

Odd Internet Explorer 7 bug; not calculating padding on links correctly

It would appear that I am suffering from a new bug in IE7, as I can't seem to find any reference to it anywhere else. It is best explained using screenshots, so here are a couple of links (and as a note, it's not a requirement for it to work in IE6, so I don't even want to know what it looks like under that!):
How it should be displayed (using Safari 4):
http://dl-client.getdropbox.com/u/45961/safari4.png
How IE7 is displaying it:
http://dl-client.getdropbox.com/u/45961/ie7.png
Here's the CSS for that menu chunk:
#mm #leftNav .navigation {
width: 100%;
margin-bottom: 0;
float: left;
}
#mm #leftNav li {
list-style: none;
display: inline;
margin: 0;
}
#mm #leftNav .navigation li ul {
display: none;
}
#mm #leftNav .navigation li a {
text-decoration: none;
color: #ffffff;
font-size: 11pt;
padding-left: 20px;
}
#mm #leftNav .navigation li {
cursor: pointer;
margin-right: 4px;
padding-left: 8px;
padding-right: 8px;
padding-top: 10px;
padding-bottom: 8px;
overflow: visible;
}
.menu_item {
background: #419185;
}
.menu_item:hover {
background: #48a093;
}
.currentcat {
background-color: #4aa8a6;
}
.currentcat:hover {
background: #4aa8a6;
}
And here is the HTML:
<div id="mm">
<div id="leftNav">
<ul class="navigation">
<li class="menu_item">
<a class="icon icon-base">Base</a>
</li>
<li class="menu_item">
<a class="icon icon-devices">Devices</a>
</li>
<li class="menu_item">
<a class="icon icon-management">Management</a>
</li>
<li class="menu_item">
<a class="icon icon-iptools">IP Tools</a>
</li>
<li class="menu_item">
<a class="icon icon-config">Configuration</a>
</li>
<li class="menu_item">
<a class="icon icon-admin">Administration</a>
</li>
</ul>
<div id="subnav"></div>
</div>
</div>
Any ideas?
top and bottom padding are not supported on inline elements (some browsers will render it, others won't)
Here's a good article on the problem:
http://www.maxdesign.com.au/presentation/inline/
If you really need correct padding, you should change the menu items to "display:block" and "float:left"
Hehe, activa beat me to it.
Indeed, move your margin/padding to the A element, kinda like so:
mm #leftNav .navigation li a {
text-decoration: none;
color: #ffffff;
font-size: 11pt;
display:block;
float:left;
background: #419185;
margin-right: 4px;
padding-left: 20px;
padding-right: 8px;
padding-top: 10px;
padding-bottom: 8px;
}
mm #leftNav .navigation li {
cursor: pointer;
}
.menu_item {
}

Resources