I'm experiencing a very frustrating problem with my CSS and IE9 and maybe even Chrome on MacOS.
I have an ul of four images in a container #categories {width: 960px}.
Each img (li) is contained in a box .catBox {width: 220px; float: left; margin: 20px 25px 10px 0px}.
I took away the right margin on the last image with .catBox:last-child {margin-right: 0px;}.
Basically, what I am trying to do is justify the four images across the 960px width container. This renders fine in Chrome, Safari, FF, and IE9 on my local computer and Chrome, Safari and FF work fine remotely from my Windows machine.
In IE when I test remotely it pushes the last image to the next line. ALSO, when testing in Chrome on a Mac it does the same thing.
Here is my math: 220px * 4 images = 880px. 3 margins (last one removed) at 25px = 75px. 75 + 880 = 955px. This should give me a 5px "buffer" in any of these browsers. Can someone please help? Am I thinking about this incorrectly?
Thanks in advance for your help.
HTML
<div id="categories">
<ul>
<li class="catBox"><img src="img/3mmwpolytongue22mm.jpg" alt=""><div class="caption"><h2>Stone</h2></div>
</li>
<li class="catBox"><img src="img/4g5.5m12ws.JPG" alt=""><div class="caption"><h2>Wood</h2></div></li>
<li class="catBox"><img src="img/5mmsnowflakeobsidianlabretA_01.JPG" alt=""><div class="caption"><h2>Teflon & Polymer</h2></div></li>
<li class="catBox"><img src="img/13mmblueindianearrings1.jpg" alt=""><div class="caption"><h2>Custom</h2></div></li>
</ul>
</div>
CSS
#categories {
width: 960px;
height: 240px;
}
.catBox {
position: relative;
display: inline;
overflow: hidden;
width: 220px;
margin: 20px 25px 10px 0px;
float: left;
z-index: -999;
}
.catBox:last-child {
margin-right: 0px;
}
.caption {
position: absolute;
top: 190px;
width: 220px;
height: 30px;
background-color: #333;
-webkit-opacity: .5;
-moz-opacity: .5;
-ms-opacity: .5;
text-align: center;
z-index: 999;
padding: 0px;
}
.caption h2 {
color: #fff;
}
Remove all whitespace between tags. It can interfere with pixel-precise layouts.
I don't see any problem. You should use tab to do whitespaces and no the space key. Here you have the JSFiddle, tested in FF, Chrome and Safari.
http://jsfiddle.net/PwkAW/
I'm not exactly sure why you're seeing the behavior that you're describing - do you know for a fact that ALL your CSS is exactly the same on the remote server? If I had to guess, there is another rule that is affecting your li's. Can you share the remote server link?
Also, your markup and CSS could be greatly simplified. I'm not saying it will fix what you're seeing, but it would at least remove some variables in the situation. You could have:
<ul id="categories">
<li>
<img src="img/3mmwpolytongue22mm.jpg" alt="" />
<h2>Stone</h2>
</li>
<li>
<img src="img/4g5.5m12ws.JPG" alt="" />
<h2>Wood</h2>
</li>
<li>
<img src="img/5mmsnowflakeobsidianlabretA_01.JPG" alt="" />
<h2>Teflon & Polymer</h2>
</li>
<li>
<img src="img/13mmblueindianearrings1.jpg" alt="">
<h2>Custom</h2>
</li>
</ul>
Then your CSS could look like this:
#categories {
width: 960px;
height: 240px;
}
#categories li {
position: relative;
display: inline;
overflow: hidden;
width: 220px;
margin: 20px 25px 10px 0px;
float: left;
z-index: -999;
}
#categories li:last-child {
margin-right: 0px;
}
#categories h2 {
position: absolute;
top: 190px;
width: 220px;
height: 30px;
background-color: #333;
-webkit-opacity: .5;
-moz-opacity: .5;
-ms-opacity: .5;
text-align: center;
z-index: 999;
padding: 0px;
color: #fff;
}
Actually, in refactoring the CSS, I did notice an issue - this rule:
catBox:last-child
Will not work the way you expect. The last-child rule, at least in my experience, doesn't work when applied to classes as part of the selector. It seems to work only on straight up elements - like #categories li:last-child. So, it may not removing the right margin as you expect.
Related
I'm using (☰) and it appears on computer even when I reduce browsers width but when I check it from my mobile browser it doesn't appear, why is that? and how to show it? Is there is another way to create or use something like this icon that would work on mobile phones?
Try using this instead:
≡
mobile browsers are more able to use this unicode character! Hope it helps
just create this hamburger with css and html
HTML:
.hamburger-icon {
margin: 0;
padding: 19px 16px;
display: inline-block;
position: absolute;
top: 0;
left: 0;
}
.hamburger-icon span {
width: 40px;
background-color: #000;
height: 5px;
display: block;
margin-bottom: 6px;
}
.hamburger-icon span:last-child {
margin-bottom:0px;
}
<label class="hamburger-icon">
<span> </span>
<span> </span>
<span> </span>
</label
I'm trying to get 2 items to display inline-block within a div but nothing I've tried is working.
The html I've used is
<div class="quotation">
<ul>
<li><img src="images/quotes.png" alt="" class="quotemarks"></li>
<li><p class="words">All honour to the Enderbies, therefore, whose house, I think, exists to the present day; though doubtless the original Samuel must long ago have slipped his cable for the great South Sea of the other world.</p></li>
</ul>
</div>
Whilst my CSS at the moment is as follows:
.quotation {
position: absolute;
margin: 20% 5% 10% 5%;
width: 88.2%;
max-height: 100px;
padding: 0.5%;
background-color: red;
color: #bdc3c7;
}
.quotation ul li {
position: relative;
display: inline-block;
text-decoration: none;
font-family: 'PT Sans', sans-serif;
font-weight: 100;
}
.quotemarks {
max-width: 20%;
}
.words {
width: 60%;
}
I cannot understand why .quotemarks and .words won't a) stay within .quotation and b) won't render inline.
You have quite some things wrong in your code and understanding of how css layout works.
You tell your list items to be display: inline-block. This tells them to be just as wide as their content.
You tell the content of your list items - the img and the paragraph - to have their width based on % - which refers to % of the width of the parent element - which happens to be the list item.
So basically the list item asks its content "How wide am I needed to be?" - while the content asks the parent list item "How wide are you? I'll be xy % of that."
It's easy to see that each element needs an answer before it can give one, creating an infinite loop of unanswered questions.
Apart from that, as soon as there is any whitespace (even a linebreak only) between two or more inline-block elements whose summed up width is 100% will make (at least) the last element wrap to a new line.
How to solve the inline-block whitespace issue: Either make your list-items float: left; (which has its own pitfalls!) or set font-size: 0; on the parent element (in this case the ul) , and re-set it on children as needed.
Also, put the width-controlling classes on the list items.
.quotation {
position: absolute;
margin: 20% 5% 10% 5%;
width: 88.2%;
max-height: 100px;
padding: 0.5%;
background-color: red;
color: #bdc3c7;
}
.quotation ul {
/*set this to avoid linebreak due to whitespace */
font-size: 0;
}
.quotation ul li {
display: inline-block;
text-decoration: none;
font-family: 'PT Sans', sans-serif;
/* re-set font-size here to what you need */
font-size: 14px;
font-weight: 100;
vertical-align: text-top;
}
.quotemarks {
max-width: 20%;
}
.words {
width: 60%;
}
.quotemarks img {
max-width: 100%;
}
<div class="quotation">
<ul>
<li class="quotemarks">
<img src="http://placekitten.com/g/200/300" alt="" />
</li>
<li class="words">
<p>All honour to the Enderbies, therefore, whose house, I think, exists to the present day; though doubtless the original Samuel must long ago have slipped his cable for the great South Sea of the other world.</p>
</li>
</ul>
</div>
Move your classes .quotemark and words to parent elements
<div class="quotation">
<ul>
<li class="quotemarks"><img src="images/quotes.png" alt=""></li>
<li class="words"><p>All honour to the Enderbies, therefore, whose house, I think, exists to the present day; though doubtless the original Samuel must long ago have slipped his cable for the great South Sea of the other world.</p></li>
</ul>
</div>
Make sure that you added necessary vertical-align rule (top, middle or bottom... ) to your list items.
Check out demo
I hope this will help.
Thanks guys, your solutions worked and, whilst my CSS is still ugly as sin, everything fits in the box and I was able to change the size of the quotemarks too.
<div class="quotation">
<ul>
<li class="quotemarks"><img src="images/quotes.png" alt=""></li>
<li class="words"><p>All honour to the Enderbies, therefore, whose house, I think, exists to the present day</p></li>
</div>
And the CSS
.quotation {
position: absolute;
margin: 20% 5% 200px 5%;
width: 88.2%;
max-height: 100px;
padding: 0.5%;
background-color: #f5f5f5;
color: #bdc3c7;
}
.quotation ul li {
position: relative;
display: inline-block;
text-decoration: none;
font-family: 'PT Sans', sans-serif;
font-weight: 100;
vertical-align: middle;
}
.quotemarks {
max-width: 20%;
margin: 0 10px 0 0;
}
.quotemarks img {
height: 40px;
}
.words {
width: 80%;
line-height: 15px;
font-size: 20px;
}
I wrote this in jsfiddle. https://jsfiddle.net/s2cq61ko/
Below is the HTML.
<div id="wrapper">
<h2>I am a generalist</h2>
<div id="Boxy">
<div id="GeneralistHeader">Stratgey & Design</div>
<div id="General_List">
<ul>
<li class="Big">systems theory</li>
<li class="Medium">branding</li>
<li class="Small">ethnography</li>
<li class="Small">statistics</li>
<li class="Big">iOS development</li>
<li class="Medium">user experience</li>
<li class="Small">web development</li>
<li class="Small">infographics</li>
</ul>
</div>
</div>
<h2>Here are past projects</h2>
<p>that will let you see my thought process.</p>
</div>
Then this is the CSS...
#wrapper {
max-width: 940px;
margin: 0 auto;
padding: 0 5%;
text-align: center;
}
a {
text-decoration: none
}
#GeneralistHeader {
font-size:2em;
font-weight: 700;
background:#19334c;
color:white;
display:inline-block;
padding: 2px 10px;
margin: -20px 0 0 0;
}
#Boxy {
border: solid;
display:inline-block;
border-width: 1px;
margin-top: 35px;
width:500px
}
#General_List ul {
list-style-type: none;
/*number of columns*/
-webkit-column-count: 2;
/* Chrome, Safari, Opera */
-moz-column-count: 2;
/* Firefox */
column-count: 2;
margin: 10px 0 0 0;
padding: 0;
font-family:'Raleway', serif;
font-weight: 400;
}
Notice the massive spacing after the box. It doesn't appear in IE or Komodo Edit's Preview. But when I open it on Chrome, it shows up like that...
I'm sure it's the CSS, but I could not figure it out.
The easiest solution is to change #Boxy to this:
#Boxy {
border: solid;
display: block; /* from inline-block to block */
border-width: 1px;
margin-top: 35px;
margin-left: auto; /* added this line */
margin-right: auto; /* added this line */
width: 500px;
}
There are a few things going on here. One is that using inline-block can produce odd spacing. If you adjust to using display block and then apply a margin-left auto and margin-right auto you will still center your box. The second thing I noticed is that you have applied a margin top of 1.75em to h2's. If you change this declaration to a class and only target the h2 that you intend to have the margin adjust then that gap goes away.
Look at this link
enter code here
You should make the Boxy on display and use margin: 0 auto; for positioning your box.
I have two image links generated like so, Here is the HTML
<ul>
<li><a class="BigLinks" href="My_Name.pdf" id="Resume" style="position: absolute; top: 264px;!important left: 17px; !important color: #0005FF"></a></li>
<li><a class="BigLinks" href="espn.com" id="Personal_Projects" style="position:absolute; top: 51em; left: 49em; color: #0005FF"></a></li>
</ul>
</div>
Here is the CSS code..
#Resume{
background-image: url(Resume_Button.png);
display: block;
border: .25em solid #FF0004;
height: 300px;
overflow: hidden;
text-indent: 200%; For Removing the hyperlink (Not Clean)
white-space:nowrap;
width: 509px;
padding-top: 5em;
padding-bottom: 5em;
}
#Resume:hover{
display:block;
border: 1em solid #FF0004;
height:15em;
overflow:hidden;
text-indent:200%; For Removing the hyperlink (Not Clean)
white-space:nowrap;
width:31em;
padding-top:5em;
padding-bottom:5em;
}
#Personal_Projects{
background-image:url(android-logo2.png);
display: block;
border: 0.25em solid #FF0004;
height:15em;
overflow:hidden;
text-indent:200%; For Removing the hyperlink (Not Clean)
white-space:nowrap;
width:31em;
padding-top:5em;
padding-bottom:5em;
}
#Personal_Projects:hover{
display: block;
border:1em solid #FF0004;
height:15em
overflow:hidden;
text-indent:200%
white-space:nowrap;
width:31em;
}
My problem is that I would like the two buttons to not be in the optimal position regardless of the size of a screen. AKA I would like the image position to be responsive no hard coded. With the way I coded it now it looks goo on my laptop screen however not on my larger TV screen.
A few problems there. Not 100% clear on what you're asking, but getting rid of the position: absolute declarations in the style attribute will reintroduce your links into the flow of the document.
Second, you're going to have difficulty getting a good result if you mix px and ems. The two don't always play nicely together.
Also, what are you trying to do with the text-indent/white-space/overflow declarations?
This is what the weird view looks like, in Chrome on OS X on first load:
That blue bar running right across the screen is actually the navigation bar that should be at the top of the screen. See below.
This is what the original view looks like, and this is what it reverts to - once I scroll down (so that portion of the screen disappears) and scroll back up:
Edit1: I don't even know what code to post, if any because it is kinda random. If you ask some questions though, maybe something might jump out and I will know what code to either post or look at.
Thanks.
Edit2: Here is the code for the div#navigation:
<div id="navigation">
<div id="quota-info">
Plan: Chameleon<br />
# of Projects: 2 / 20<br />
# of Clients: 2 / 15<br />
Storage: 10.8 MB / 10.0GB <br />
</div>
<div id="user-info">
<span class="username">Hi Test</span><br />
Name: Test User<br />
Email: test#abc.com<br />
Last Logged In: about 2 hours ago<br />
</div>
<ul>
<li><img src="logo.png" /></li>
<li id="dashboard">Dashboard</li>
<li id="settings">Settings</li>
<li id="logout">Logout</li>
</ul>
</div>
Here is the CSS:
#navigation {
font-family: Verdana, Arial, sans-serif;
font-size: 13px;
background: #2d343f;
background-image: url('../images/nav-textured-bg.png');
background-repeat: repeat;
padding: 5px 5px;
margin: 0px auto;
position: relative;
height: 75px;
}
#navigation a {
text-decoration: none;
padding: 10px 15px;
display: inline;
height: 35px;
line-height: 35px;
color: #c6c8cb;
}
#navigation ul {
width: 100%;
margin: 0 auto;
text-align: center;
}
#navigation li {
width: 100%;
display: inline;
list-style-type: none;
}
#navigation li img {
position: relative;
top: 15px;
}
Edit 3:
Here is another screenshot of how it looks when I scroll up. The top navigational bar is still there. This blue thing is not even the menu, it's like a screenshot of it. When I hover over the menu links, they don't work.
You have to create a reduction. Start with a copy of the actual page and then remove stuff not related to the problem, one by one, until it disappears. Then you'll see what's causing it, whether it's a browser bug and what you can do to fix it.
PS: If it's a browser bug, don't neglect to report it. It's a web developer's responsibility.
I would start by cleaning up some of your CSS.
#navigation {
font-family: Verdana, Arial, sans-serif;
font-size: 13px;
background: #2d343f;
background-image: url('../images/nav-textured-bg.png');
background-repeat: repeat;
padding: 5px 5px;
margin: 0px auto; <--- see below
position: relative;
height: 75px;
}
this should be margin:0 since it's a block element. Block elements take up the entire line, so trying to center it makes no sense.
#navigation a {
text-decoration: none;
padding: 10px 15px;
display: inline; <--- conflict (see below)
height: 35px; <--- conflict (see below)
line-height: 35px;
color: #c6c8cb;
}
Inline elements can't have a width or height applied to them, but some browsers when you try to will automatically convert any inline element to inline-block for you. If that is what you want, you should specify it, otherwise drop the height.
#navigation ul {
width: 100%;
margin: 0 auto; <-- see below
text-align: center;
}
Centering an item with 100% width does not make sense here
#navigation li {
width: 100%; <--- conflict
display: inline; <--- conflict
list-style-type: none;
}
#navigation li img {
position: relative;
top: 15px;
}