CSS layout problem: tabs should overlap the frame - html

I'm working on a template like this:
The as you can see the frame (3) has a glassy border which goes behind the tabs (1,2). But I don't know how to do this layout in CSS. I searched stackoverflow and found the following threads, but they didn't help:
https://stackoverflow.com/questions/6649360/how-to-overlap-put-a-frame-layout-from-top-border-of-an-imageview
CSS problem, creating tabs
The HTML code is something like this:
<div id="frame">
<nav>
<ul id="topnav">
<li>Tab1</li>
<li>Tab2</li>
<li>Tab3</li>
<li>Tab4</li>
<li>Tab5</li>
<li>Tab6</li>
<li>Tab7</li>
</ul>
</nav>
</div>

Try This
HTML :
<div id="frame">
<ul>
<li>Tab 01</li>
<li>Tab 02</li>
<li>Tab 03</li>
<li>Tab 04</li>
</ul>
</div>
<div id="frame2">Frame 02</div>
CSS :
#frame,#frame ul
{ height:30px;
background:#f0f0f0;
}
#frame ul li
{ height:30px;
float:left;
padding-right:2px;
}
#frame ul li a
{ position:relative;
height:30px;
display:block;
float:left; /* for IE6 bug */
background-color:#f00;
left:0;
top:0;
padding:0 4px;
color:#fff;
}
#frame ul li a:hover,#frame ul li a.active
{ height:40px;
}
#frame2
{ border:#000 1px solid;
padding:10px;
}
Please Check JSFIDDLE for Reference

I think you are looking for the z-index. An element with a higher z-index will appear above another element with a lower z-index. you can use something like this:
.tabSelected {
z-index: 99;
}

I would suggest having a look at jquery-ui which provides an example on the site of a tabbed element such as this, you can modify the design using the theme roller on the site to get the colours you want.
jquery ui tabs

If you're using CSS3, you could try using RGBA for the background colour of the frame - here's a couple of links:
SO question/answer
CSS Tricks article
RGBA will allow the divs to be slightly transparent while keeping the contents visible - just make sure the frame is slightly larger than the contents (so it can be seen) and set the background colour to match the glass effect.

Related

Drop Down Alignment

I am working on a supposedly simple drop down menu using HTML and CSS, and have encountered an issue. After scouring google and the forums to no avail, figured it was time to ask. I am trying to get the drop down menu to line up with it's parent element.
I have experimented with a few different methods, so far the most hopeful seems to be setting the "left:" value to the necessary percentage.
This brings up another issue though:
Issue: when I set the left value, I end up with a bunch of blank space to the right of the item that I can't seem to get rid of. Can't get the width right.
Code located here: https://jsfiddle.net/c6mz3t08/5/
HTML
<div id="navbar-top">
<ul class="horizontal">
<li>Home</li>
<li>About
<ul>
<li>Menu 1</li>
<li>Menu 2</li>
</ul>
</li>
<li>Header</li>
<li>Header</li>
<li>Header</li>
</ul>
CSS for dropdown
.horizontal li ul {
opacity:0;
visibility:hidden;
text-align:left;
position:absolute;
top:50px;
left:-38%; //end up with blank space on right?
}
.horizontal li ul li {
position:relative;
background-color:#BBB;
display:block;
width:100%;
}
It seems the alignment problem happens because the <ul> starts after the word "About" in the second <li>.
a.) for positioning adjust the leftparameter in .horizontal li ul (-39px seems to work well).
b.) for the width of the submenus adjust the width parameter in .horizontal li ul li (70px worked well here, but depends on the content)
Do not guess on the left. The reason it is pushed to the right is because the ul has by default some padding.
Setting the padding to 0 and the left to 0 will fix this.
The space on the right is added because you set the width to 100%. If you remove the width it will fit its container. But that might not be what you want because the text will wrap, it might be better to set white-space:nowrap on it.
.horizontal li ul {
opacity:0;
visibility:hidden;
text-align:left;
position:absolute;
top:50px;
padding:0;
left:0; //using the LEFT parameter to get it in to alignment--end up with "blank" space on right?
}
.horizontal li ul li {
position:relative;
background-color:#BBB;
display:block;
white-space:nowrap;
}
Updated demo at https://jsfiddle.net/c6mz3t08/6/

Why is my navbar scaling the page on mobile?

My website has a scaling problem on the chrome browser in android on mobile. This does not happen in Firefox on mobile or in any desktop browser. When the navbar is selected and drops down, it scales the webpage. Note that the page is scaled differently depending on which dropdown has been selected. It seems as though the navbar has invisible content that is breaking frame when the dropdown behavior is engaged.
I have stitched together 4 screenshots of the issue.
Help with either a fix or a workaround would be much appreciated.
#NavigationBarList{
list-style-type:none;
padding:0;
}
li{
font-size:130%;
}
nav a{
display:block;
}
/* This customizes the presentation of the list elements (menu items) in the navbar. */
nav li{
display:block;
font-weight:bold;
font-size:200%;
color:#7F1717;
background-color:#9E939E;
width:25%;
text-align:center;
text-decoration:none;
text-transform:uppercase;
z-index:11;
-moz-box-shadow: inset 0 0 1px #000000;
-webkit-box-shadow: inset 0 0 1px #000000;
box-shadow: inset 0 0 1px #000000;
}
nav ul{
width:100%;
}
/* Hide the sub menu items. */
nav ul ul {
display:none;
}
nav ul ul ul {
display:none
}
/* When hovered over, the CSS menu will drop down. */
nav li:hover > ul {
text-align:center;
font-size:40%;
display:block;
}
/* Don't underline links in the list elements (menu items). */
ul a {
text-decoration:none;
color:#7F1717;
}
/* Change the background color of hovered list elements. This was both active and hover... */
nav li:hover{
background-color:#625C62;
}
/* This customizes the ul elements in the sub-menu. */
nav ul ul{
position:absolute;
padding:0;
width:100%
}
nav ul ul ul{
position: absolute;
width:400%;
left:100%;
top:0;
}
#totheleft{
left:-100%;
}
nav ul ul ul li{
text-align:center;
font-size:250%;
}
/* I think this refers to the dropdown navbar location and properties. */
nav ul ul li {
position:relative;
}
<nav>
<ul id="NavigationBarList">
<li style="float:left;">Events
<ul>
<li>Tournaments</li>
<li>Kid's Hour</li>
<li>Local Calendar</li>
</ul>
</li>
<li style="float:left;">Programs
<ul>
<li>Summer Camps</li>
<li>In Schools
<ul>
<li>After School</li>
<li>Registration</li>
</ul>
</li>
<li>Local Instructors</li>
</ul>
</li>
<li style="float:left;">Content
<ul>
<li>Posts</li>
<li>Games
</ul>
</li>
</li>
<li style="float:left;">Connect
<ul>
<li>Contact Us</li>
<li>Resources
<ul id="totheleft">
<li>Chess</li>
<li>Go</li>
<li>Xiangqi</li>
<li>Shogi</li>
<li>Backgammon</li>
</ul>
</li>
<li>About Us</li>
</ul>
</li>
</ul>
</nav>
Add this to the head section of all your pages.
<meta name="viewport" content="user-scalable=0">
From the google developers site
Without a viewport, mobile devices will render the page at a typical desktop screen width, scaled to fit the screen.
So when you visit the webpage on mobile, the view is actually zoomed out to fit all your content. When you touch your navbar, the browser also tries to zoom in. Setting user-scalable=0 prevents this from happening.
The downside is your users will no longer be able to scale the zoom on the website on mobile, but the only alternative would be to rewrite your website to use a fluid layout.
Your <ul>s that contain the dropdown items have width=100%. This means the width will be 100% of the first relatively positioned parent (which in this case is the <body>). This is causing an overflow on the x axis.
You could make the <ul>s 25% width and the <li>s inside 100%, instead of what you have now where the <li>s are 25%.
Giving you
/* This customizes the ul elements in the sub-menu. */
nav ul ul{
position:absolute;
padding:0;
width:25%;
}
and
/* I think this refers to the dropdown navbar location and properties. */
nav ul ul li {
position:relative;
width:100%;
}
I went to your site and checked it out real quick... I noticed you are using absolute positioning to position your content in the center of your page. I assume this is what is causing your issue.
I would look up a tutorial on how to create a repeating background image and use that instead of trying to use one image with no repeat. then you can center your content with margin: 0 auto.
I know its not a definite answer but I hope it nudges you in the right direction.
The workaround I came up with was to set overflow-x:hidden on my overlay. I had tried this previously on the body, but on Android overflow-x does not work on the body; it must be set for a container. There is presumably a related reason that this issue only arose on Android. This workaround works perfectly.

Justified horizontal list with minified HTML

For a horizontal menu i want to justify the list items over the full width.
This works:
CSS:
ul {height: 1em;text-align: justify;overflow: hidden;padding-left: 0;}
li {display: inline-block;}
li:last-child {padding-left: 100%;}
HTML:
<ul>
<li>flexible number</li>
<li>and length of</li>
<li>list items</li>
<li>hidden</li>
</ul>
OUTPUT (the lines are showing the width of the UL):
|flexible number and length of list items|
If i delete all whitespaces and linebreaks to minify the HTML-output, it doesn't work any more.
SMALLER HTML:
<ul><li>flexible number</li><li>and length of</li><li>list items</li><li>hidden</li></ul>
It looks like this:
|flexible numberand length oflist items |
Is there any chance to get the "normal" behavior back with pure CSS?
Please have a look at this fiddle:
http://jsfiddle.net/Tfranz/HpP99/
Check out the jsFiddle below - you should be able to use % widths and floats to do this without padding or margins. Standard minification should not affect the results.
http://jsfiddle.net/MNally/CWjMz/
HTML:
<div id="container">
<ul id="the-list">
<li>item1</li>
<li>item1</li>
<li>item1</li>
</ul>
</div>
CSS:
div#container {
width:100%;
padding:0;
margin:0;
}
ul#the-list {
width:100%;
text-align:center;
}
li {
float:left;
display:inline;
padding:0;
margin:0;
background:#c9c;
width:33.333%;
}
I set the margin/padding to '0' to illustrate that they're not needed. You can remove these lines.
How about using display:table; and display:table-cell; ?
See here: http://jsfiddle.net/HpP99/2/
I ran into the same exact problem. HTML minification removes whitespaces as we all know, but in this case it breaks the CSS "text-align: justify" and "text-align-last: justify".
The solution is to implement a single line jQuery code to add white spaces back after the closing tags for the list items:
$('#the_list li').after(" ");
I hope someone finds this helpful.

Why are my z-indexed list items stacking on top of each other?

Thanks in advance for any help...
As part of learning HTML and CSS, I'm working on a responsive long scroll page with a small handful of large images breaking up a few different sections. Ultimately, I'd like to switch those large images to background images in CSS, but for sake of this question, I've got them inline.
I'm trying to use z-index to then stack some other link images on top of the main large image (bg1). To create the very basic layout, I created a ul with 2 li containing the large images (bg1 and bg2) and then created a second ul within one of the parent li. That makes sense in my head though I'm sure I'm screwing up some terminology.
Long story short, I have 3 social media icons that I'd like displayed in a row as part of this sub-ul. The problem is although I can get them to stack on top of the main image (bg1), they also stack on top of each other which means you can only actually see one of the social media icons. I would've thought that display:inline-block in my CSS would fix that? If I switch the position on .social-media to relative, it will then line them up correctly, but it is no longer on top of my main image (bg1).
On a side note, I'd ultimately like to get the background images into the CSS. If I do it as a static page, it works fine, but there's some jquery based responsiveness that I haven't been able to get to work correctly for resizing those images... I'll tackle that next but for now, I'm trying to understand how to fix what's going on now.
Thanks again!
My HTML:
<body>
<ul id="frames" class=" ">
<li id="landing-frame" class="landing" style="position:relative; min-height:1px; height:auto; overflow:visible">
<img src="images/bg1.jpg"/>
</li>
<li>
<ul class="social-media">
<li><img src="images/facebook-pink.png" /></li>
<li><img src="images/blog-icon.png" /></li>
<li><img src="images/facebook-blue.png"/></li>
</ul>
</li>
<li id="links-frame" class="links " style="position:relative; min-height:1px; height:auto; overflow:visible">
<img src="images/bg2.jpg"/>
</li>
<li id="gallery-frame" class="gallery " style="position:relative; min-height:1px; height:auto; overflow:visible">
<h1>Gallery</h1>
</li>
</ul>
My CSS:
html, body{
margin: 0;
height:100%;
list-style-type:none;
}
.landing{
width:100%;
height:100%;
background:#ffffff;
}
.landing img{
width:100%;
height:100%;
z-index:999;
vertical-align:middle;
}
.social-media li {
display:inline-block;
z-index:998;
position:absolute;
bottom:10%;
left:45%;
text-align:center;
float:left
}
.social-media img {
width:50%;
height:auto;
}
You are targeting your CSS wrong. You need to give .social-media position: absolute;, not the li item.
.social-media {
z-index:998;
position:absolute;
bottom:10%;
left:45%;
text-align:center;
}
.social-media li {
display:inline-block;
}
Working Example
try this
.social-media {
display:block;
z-index:998;
position:absolute;
bottom:10%;
left:45%;
text-align:center;
float:left
}
.social-media li {
display:inline-block;
}

Input Tag Messing Up Alignment

So, in my header, I have a horizontal list of links. Next to them, I wanted a search bar, but when I insert it next to my links, all of them now appear behind my body div.
HTML:
<ul id="unordered">
<li>LInk1</li>
<li>Link 2</li>
<li>Link 3</li>
<li>Link 4</li>
<li><input type="text"></li>
</ul>
CSS:
#unordered {
display:inline-block;
height:0px;
padding-bottom:5px;
margin-left:400px;
}
#unordered li a{
text-align:center;
color:white;
text-decoration:none;
font-size:18px;
list-style-type:none;
}
#unordered li {
list-style-type:none;
display:inline;
padding-left: 0px;
padding-right: 55px;
padding-bottom: 15px;
}
#unordered li link {
list-style-type:none;
margin-bottom: 10px;
}
Here's screenshots of before and after...
Before: http://prntscr.com/2jfi8i
After: http://prntscr.com/2jfhxz
Thank you.
Edit: I noticed that I forgot form tags. After I inserted them, it's no longer hidden behind the body div, but the links are now above the text box.
So I think what's happening is your #unordered is not wide enough with the position you give it. The text field shifts down. The following fixed it
#unordered {
display:inline-block;
height:0px;
padding-bottom:5px;
margin-left:100px; /*It's 100px instead of 400px, the ul is wider*/
}
There are other ways to fix it, the above is just one way.
Update
I removed the form tags, unless you really want those? (they were not in the original code) I then removed the height:0px which resolved the body appearing to be in front of the ul element. It was not allowing for any padding/margin below the text element. Again though, if the page stretches (the width increases) out the text input re-renders inline with the rest.
Please see Fiddle Update