I'm redesigning my company's website and am trying to create a horizontal navigation bar with button links (which I've managed somewhat). The problem is that the exact same menu is supposed to appear on every page (of which there are 100+) and the button options may increase of decrease in the future.
My question is this: Is there a way to place the button text and associated links in the external css to make re-coding and future edits to all those pages simpler? I've searched and tried everything I could think of. The below code is still very much a work in progress, so any advice would be appreciated.
Relevant css:
/* BEGIN Menu Buttons*/
#menu {text-align:center;}
#menu ul {
display: inline-block;
list-style-type: none;
text-align: center;}
#menu ul li {
float: left;
width: 140px;
height:50px;
list-style-type:none;}
#menu li a {
width: 130px;
height:40px;
padding:5px;
display:block;
color: #fff ;
background-color: #000 ;
font: Times New Roman;
font-size:14pt;
line-height:40px;
text-align:center;
text-decoration: none ;
border-right:1px solid #fff;
border-left:1px solid #fff;
border-top: 1px solid #fff;
border-bottom: 1px solid #fff;;}
#menu li a:hover {
border-top: 3px solid #000;
border-bottom: 3px solid #000;
outline: 1px solid #fff;
font-size:16pt;}
/* END Menu Buttons*/
Relevant HTML:
<header>
<div id="menu">
<ul>
<li>Home</li>
<li>Buy</li>
<li>Sell</li>
<li>Maintenance</li>
<li>Parts</li>
<li>Information</li>
<li>Contact</li>
</ul>
</div>
</header>
If I understand your question correctly, the solution I would use is PHP
First of all you would need to save your page to .php for this to work (instead of .html)
Secondly, create a new file (menu.php) and paste in the MENU code above.
In every page that you have, you replace the menu HTML code with this:
<?php
include 'menu.php';
?>
(assuming you put the menu.php in the same folder as the rest of your pages)
Now, if the content of your menu expands, just edit menu.php and your menu is updated on all pages that have your menu.php file included.
Another solution for you, If you aren't using php and you need an html solution, you can always lean on the iframe.
<iframe id="iframe" src="xxx.html" width="500" height="180"></iframe>
but the problem with this is you woudl need to update the width on every page, should your menu become larger (wider) than this iframe accounts for.
Related
I'm not sure how to deal with anything(except images) that is used for design/decoration only in terms of accessibility. For example, if in case like this I'll use an image, I'd simply use alt="" or use CSS background image, so the AT for example will ignore it. But what if I'm using some <div> or anything else? It can be a div with some CSS styling that is presented in a code-way, instead of image, or it can be some text with CSS styling so it will be just for decoration(instead of images), or really, anything else. How should I mark it so it will be ignored in a proper way by AT?
Simple example(for request):
<div><span>For Decoration</span></div>
div{
width:0; height:0;
border-bottom:116px solid #009;
border-left:500px solid #900;
margin:0 auto;
}
div span{
display:block;
position:absolute;
margin:0 auto;
left:0;
right:0;
width:150px;
color:#fff;
}
There are two solutions to this:
1) if you are using an empty tag such as a div with no text in it, the screen reader will ignore it automatically. You don't need to do anything in particular.
2) if you are using a tag with text inside you should: a) give it an aria-hidden="true" if you don't want the screen-reader to read the text or b) give it a role="presentation" if you do want the screen-reader to read the text but not announce it as a particular type of element.
-------------------
Based on the comments on this post I have added code below showing an example. It shows when you wouldn't need to do anything (the first and last div) and when you would want to use aria-hidden and role="presentation".
The top line is purely for decoration. Part of it is empty divs and part of it is text. The different words for "Hello" in the p tag should be seen but don't need to be read since they're purely ornamental which is why I am using role and aria-hidden on it.
.end {
display: inline-block;
width: 5%;
height: 20px;
border: 5px solid transparent;
}
.end-left {
border-left-color: #999;
border-top-color: #999;
}
.end-right {
border-right-color: #999;
border-top-color: #999;
}
.languages {
display: inline-block;
width: 80%;
text-align: center;
font-family: 'copperplate', 'century gothic';
color: #999;
}
.languages span {
display: inline-block;
width: 15%;
}
<div class="end end-left"></div>
<p class="languages" aria-hidden="true" role="presentation">
<span class="english">Hello</span>
<span class="french">Bonjour</span>
<span class="italian">Ciao</span>
<span class="spanish">Hola</span>
<span class="hinid">Namaste</span>
<span class="persian">Salaam</span>
</p>
<div class="end end-right"></div>
<h1>Languages</h1>
<p>Welcome to your first language lesson. You will learn how to speak fluently.</p>
i am trying design a thumbnail with the latest pictures uploaded in my site. In the project use bootstrap twitter.
The thumbnail works fine, except by a little detail. The thumbnail contains 3 rows with 4 columns, in the second row, exist a space in the first,second and third list place. It is a screen:
The html code is generated with Smarty, it is the code, and works fine:
<ul class="thumbnails lastFotos">
{foreach from=$last_fotos item="foto"}
<li class="span1"><a class="thumbnail"><img src="{$BASE_URL}/assets/img/galeria/{$foto.Nombre}" alt="{$foto.Nombre}"/></a></li>
{/foreach}
</ul>
Thumbnails, thumbnail and span1 are classes of Bootswrap, whereas that lastFotos is a class created for my, to change some configuration of Bootstrap:
ul.lastFotos{ margin-left: 22px; }
ul.lastFotos li{ display: inline; margin-bottom: 7px; margin-left: 5px; }
ul.lastFotos li a{ border-radius: 0; padding: 2px; }
ul.lastFotos li a:hover{ border-color: #8e84b8; }
Any ideas ?.
this is because image are of different sizes, give a height to list or image it will fix it
like
ul.lastFotos li {height:60px;}
or
ul.lastFotos li img{width:60px;height:60px;}
I've seen tons of ie css questions, but none that seem to address what I'm asking here. Forgive me if I've missed one and asked a dupe:)
I have a website (asp.net mvc2, c#) littered with links similar to this:
<a href="<%= Url.Action("Action", "Controller")%>">
<div class="buttons">
<button type="button"> Click Me</button>
</div>
</a>
These work fine in Chrome, FF and Safari, but not in IE9. The button itself seems to cancel out the link. In other words, the link is only active on the very outer edge of the button (if at all).
I'm not very fluent with Css, but here's the relevant bit (I think, though I suppose the problem could lie elsewhere...):
.buttons a, .buttons button{
display:inline-block;
text-align: left;
float:left;
margin:0 7px 0 0;
background-color:#f5f5f5;
border:1px solid #0b0101;
border-top:1px solid #eee;
border-left:1px solid #eee;
font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
line-height:130%;
text-decoration:none;
font-weight:bold;
color:#565656;
cursor:pointer;
padding:5px 10px 6px 7px; /* Links */
}
.buttons button{
width:auto;
overflow:visible;
padding:4px 10px 3px 7px; /* IE6 */
}
.buttons button[type]{
padding:5px 10px 5px 7px; /* Firefox */
line-height:17px; /* Safari */
}
Does anyone know a workaround or hack for this? Thanks!
I'm not sure what you're trying to achieve with a <button> tag inside an <a> tag, but it isn't valid HTML, so it's no surprise it's not working properly -- perhaps more of a surprise that it is working in some browsers.
In any case, there's no need for this kind of thing, as an <a> tag can be styled to look and work like a button without needing any additional elements inside it.
For example, see http://www.cssbuttongenerator.com/ which produces CSS for a plain <a> tag with nothing inside it except the button text.
There are dozens of other sites with similar tutorials and techniques, but the basic advice I'd give you hear is to drop the <div> and the <button> and just go with a plain <a> tag.
Hope that helps.
Thanks for the feedback. I didn't realize wrapping a button in an <a> tag was invalid, but sure enough, it is. Anyway the simplest fix for this, imo, was dropping the <a> tag, and adding
onclick="window.location.href='<%=Url.Action("Action", "Controller")%>'"
to the <button> element, essentially turning the button into a link.
Have a page to install links to other sites with link inputs as follows:
<div id="mainContent">
<div id="links">
Go To Google
Go To Yahoo
Go To ESPN
Go To ABC News
Go To Youtube
</div>
</div>
controlled by the following css in an external stylesheet
div#links a {
width:550px;
display:block;
margin-left:10px;
margin-top:2px;
padding: 2px 5px 2px 5px;
text-decoration:none;
font-family:arial;
font-weight:bold;
text-align:center;
background-color: black;
color: white;
font-size:9pt;
border: 3px red ridge;
}
a:hover {
background-color:navy;
color:red;
font-style:italic;
}
The display including the hover worked when operated in a standalone situation with the css in the head, however when I move it into a real content area in a page and install the css in the external style sheet the hover no longer works!
You are probably not linking to your stylesheet the right way.
Either you haven't linked it at all:
<link href="/style/style.css" rel="stylesheet" type="text/css">
Or you are using a local path:
You should (almost) always use relative paths for linking to content on the web.
So:
http://example.com/style/style.css
or
file://host/path/style/style.css
becomes
/style/style/css
If you take a look at http://www.jumo.com/about, you will notice that the three links on the nav are set up as anchors. Looking at the code, we can find that the CSS responsible for this is:
/* ?OPTIONS? */
.section_options {
border-bottom:1px solid #94CB41;
display:none;
font-size:14px;
margin-bottom:25px;
margin-top:0;
padding-left:10px;
width:98%;
z-index:20;
line-height: 21px;
}
.section_options a {
border:1px solid #cccccc;
border-bottom:0px solid #cccccc;
color:#555555;
margin-right:9px;
opacity:0.6;
padding:9px 14px 2px;
}
.section_options a.selected {
background:white;
font-weight:bold;
color:#555555;
opacity:1;
padding-bottom:3px;
border:1px solid #94CB41;
border-bottom: 1px solid white;
margin-left:4px;
}
as well as this in the HTML
<style>
#about, #team, #contact { display:none; }
</style>
Going further down into the HTML, we can see where these sections are called -
<div class="section_options" id="section_nav" style="display: block;">
About Us
Our Team
Contact
</div>
<div id="about" class="section">
and
<div id="team" class="section">
and
<div id="contact" class="section">
Yet when I apply this code I just get the three tabs being displayed, but nothing else,and the anchor links do nothing. I know if I change the {display:} to block or inline it will display the content, but the selection of the links does not work, the anchoring has no effect. Does anyone know why this is? I have a feeling it has something to do with the section_nav not being declared in the CSS, but not sure.
Thank you!
The page you are looking at uses JavaScript to switch between tabs and apply/remove the selected class to/from the active tab header. If you want to see how they do it, you can download their scripts.