I want to display these 3 grey buttons on the banner. Everything i tried didn't work.
This is the html code:
<nav>
<img class="banner" src="img/Banner.png" alt="Banner">
<table>
<tr>
<td>
Index
</td>
<td class="separator">
<td>
<a class="active" href="seiteA.html">Seite A</a>
</td>
<td class="separator">
</td>
<td>
Seite B
</td>
</tr>
</table>
</nav>
I am new to HTML and CSS so i appreciate any help :)
Best practices:
It is not a good practice to use a <table> for navigation, you can use something like <ol>/<ul> as shown in nav documentation on MDN or even <div>s within display:flex container.
You can use the image as the background-image of the <nav> so that you don't have to position the navigation elements on top of it yourself.
nav {
position: relative;
height: 100px;
padding: 10px;
background-image: url("https://picsum.photos/100");
}
ol {
display: flex;
justify-content: space-around;
list-style: none;
}
li {
padding: 5px;
background: white;
}
<nav>
<ol>
<li>Seite A</li>
<li>Seite B</li>
<li>Seite B C</li>
</ol>
</nav>
Quick answer to help you move forward with what you currently have: You can make your nav a relative positioned container and absolute position your table on top of it anywhere you want.
nav {
position: relative;
}
img {
display: block;
height: 200px;
background-color: dodgerblue;
}
table {
position: absolute;
top: 50px;
left: 50%;
}
<nav>
<img class="banner" src="img/Banner.png" alt="Banner">
<table>
<tr>
<td>
Index
</td>
<td class="separator">
<td>
<a class="active" href="seiteA.html">Seite A</a>
</td>
<td class="separator">
</td>
<td>
Seite B
</td>
</tr>
</table>
</nav>
Related
I am working on a menu where I want three of the buttons aligned to the left, two things aligned to the right and one other option aligned in the center. I am currently accomplishing this by adding padding to the center aligned one, but I feel as though there is a better way to do this. Especially when someone uses a screen of smaller resolution, such as a cell phone.
Here is what I have so far:
<html>
<head>
<style type="text/css">
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
text-decoration: none;
}
</style>
</head>
<body>
<body bgcolor="#71AAE2">
<div align="center">
<table style="border-collapse: collapse;" border="0" width="1200" cellpadding="0" bgcolor="#6699FF">
<tr>
<td width="800">
<p align="center">
</td>
</tr>
<tr>
<td width="800">
<ul>
<li>Home</li>
<li>Gallery</li>
<li>Contact Us </li>
<li style="float:right"><a href="http://www.gltdc.net/" target="_blank" ><img src="images/GLTDC.png" style="padding:7px 7px;" width="80" height="38"></li>
<li style="float:right;padding:18px 0px;display: block;color: white;text-align: center;text-decoration: none;">PROUD MEMBER OF THE</li></a>
<center><li style="display:inline-block;margin-left: 24%;">Employee Login</li></center>
</ul>
</td>
</tr>
</table>
</div>
</body>
</html>
So what would be the best way to center that "Employee Login"?
I am a newbie in HTML and currently working on my University project work and I really need some help. I am using a background box for the "blog-like" website which needs to align title and short text on the left and contents with hyperlinks on the right.
So far I have used a cell to align them but to say the least, it looks very ugly and moreover affects spacing. No matter what I tried I can't change the contents on both sides without a response from another. Is it possible to arrange content somehow another way instead of using a single cell for an entire box and dividing percentage for each side? I have uploaded a picture of the website below
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
Your Personal Guide To Best Hardcore Events
</title>
<style type="text/css">
body {
background: url(http://webprojects.eecs.qmul.ac.uk/at315/background.jpg);
background-repeat: no-repeat;
background-size: 100% 100%;
background-attachment: fixed
}
.background {
display: flex;
justify-content: center;
}
div.transbox {
margin: 0px;
background-color: #ffffff;
border: 1.5px solid black;
opacity: 0.6;
filter: alpha(opacity=60);
width: 100%;
max-width: 1300px;
}
</style>
</head>
<body>
<p align="center">
<img src="http://webprojects.eecs.qmul.ac.uk/at315/header.png" style="width:70%;" border="0" alt="" />
</p>
<div class="background">
<div class="transbox">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<th width="75%" align="left">
<h2>
Articles:
</h2>
</th>
<th width="20%" align="center">
<ul style="list-style: none;">
<li>
Homepage
<br />
<br />
</li>
<li>
<small><a href="http://www.qmul.ac.uk" style=
"text-decoration:none">Architects</a></small>
</li>
<li>
<small><a href="https://www.facebook.com" style=
"text-decoration:none">Northlane</a></small>
</li>
<li>
<small><a href="http://www.bbc.co.uk" style=
"text-decoration:none">Attila</a></small>
</li>
</ul>
</th>
</tr>
<tr>
<td align="left">
<h4>
<strong>Architects Rocking Brixton</strong>
</h4>Read our article about Architects headlining their biggest sold-out UK show!
<hr />
</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td align="left">
<h4>
<strong>Architects Rocking Brixton</strong>
</h4>Read our article about Architects headlining their biggest sold-out UK show!
<hr />
</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td align="left">
<h4>
<strong>Architects Rocking Brixton</strong>
</h4>Read our article about Architects headlining their biggest sold-out UK show!
<br />
<br />
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
Main page of the website
In this situations it is best to use flex and max width. It is very good to responsive design so.
.background {
display: flex;
justify-content: center;
}
div.transbox {
margin: 30px;
background-color: #ffffff;
border: 1px solid black;
opacity: 0.6;
filter: alpha(opacity=60);
width: 100%;
max-width: 1000px;
}
Change your browser size, It work good for all sizes. And the best part is if the screen has width < 1000px the table fills all of the screen.
just change this tag:
<table style="padding:0 5% " width = "90%" border="0" cellpadding="0" cellspacing="0">
I have two images, link and two ul's inside one td element, is there any way to inline them? http://jsfiddle.net/akeo4zmw/
<table>
<tr>
<td id="menu"><div>
<img src="imgs/logo_03.jpg" /></div>
<div>
<ul id="leftsidemenu">
<li>Woman</li>
<li>Men</li>
<li>Kids</li>
<li>Coming Soon</li>
<li>About</li>
</ul>
</div>
<div>
<ul id="rightsidemenu">
<li>Log In</li>
<li>Basket</li>
</ul>
</div>
<div>
<img src="imgs/images/images/search_05.jpg" />
</div>
</td>
</tr>
</table>
Just give float left to all the div elements.
body {
background-color: #e5e5e5;
}
table {
border: 1px solid;
border-spacing: 0;
background-color: #ffffff
}
table td {
vertical-align: top;
}
#leftsidemenu li,
#rightsidemenu li {
display: inline;
}
div {
display: inline;
float: left;
}
<table>
<tr>
<td id="menu">
<div>
<img src="imgs/logo_03.jpg" />
</div>
<div>
<ul id="leftsidemenu">
<li>Woman</li>
<li>Men</li>
<li>Kids</li>
<li>Coming Soon</li>
<li>About</li>
</ul>
</div>
<div>
<ul id="rightsidemenu">
<li>Log In</li>
<li>Basket</li>
</ul>
</div>
<div>
<a href="https://www.google.ru/webhp?tab=ww&ei=b0nuVK3LEoeiyAO7yYC4Bg&ved=0CAYQ1S4">
<img src="imgs/images/images/search_05.jpg" />
</a>
</div>
</td>
</tr>
</table>
Could you please explain me why the 2nd, 3rd and 4th images in this jsfiddle get smaller and smaller in size?
http://jsfiddle.net/FdhL6/
Here is the HTML from the JSFiddle.
<div id="album">
<table border="1">
<tr>
<td><img src="http://i.imgur.com/dj7aqdo.jpg"/></td>
<td><img src="http://i.imgur.com/dj7aqdo.jpg"/></td>
<td><img src="http://i.imgur.com/dj7aqdo.jpg"/></td>
<td><img src="http://i.imgur.com/dj7aqdo.jpg"/></td>
<td><img src="http://i.imgur.com/dj7aqdo.jpg"/></td>
</tr>
<tr>
<td>Caption 1</td>
<td>Caption 2</td>
<td>Caption 3</td>
<td>Caption 4</td>
<td>Caption 5</td>
</tr>
</table>
</div>
Here is the CSS.
#album {
overflow: auto;
}
#album td {
width: 40%;
}
#album img {
width: 100%;
}
I am trying to make a photo album with a horizontal scrollbar in the #album div. I want each image to be 40% of the width of the page. Now, with this width, only two and a half image would fit in the page. I want a scrollbar to appear for the remaining pictures in the #album div. The #album div should not exceed the width of the page.
Don't use tables for this. They present their own problems.
http://jsfiddle.net/michaelburtonray/FdhL6/2/
HTML
<div id="album">
<ul class="stage">
<li class="image-wrapper">
<img src="http://i.imgur.com/dj7aqdo.jpg"/>
<span>Caption 1</span>
<li class="image-wrapper">
<img src="http://i.imgur.com/dj7aqdo.jpg"/>
<span>Caption 2</span>
<li class="image-wrapper">
<img src="http://i.imgur.com/dj7aqdo.jpg"/>
<span>Caption 3</span>
<li class="image-wrapper">
<img src="http://i.imgur.com/dj7aqdo.jpg"/>
<span>Caption 4</span>
<li class="image-wrapper">
<img src="http://i.imgur.com/dj7aqdo.jpg"/>
<span>Caption 5</span>
</ul>
</div>
CSS
#album {
overflow: auto;
}
ul.stage {
padding-left: 0;
white-space: nowrap;
width: 200%;
}
li.image-wrapper {
display: inline-block;
width: 20%;
}
img {
display: block;
width: 100%;
}
span {
display: block;
}
AS j08691 said, you are using 200% width of 100%, that is what is causing your results to be so wonky. You should only be allocating 100% of your width otherwise your overflow your container, jsFiddle might be compensating for this and causing the images to get smaller.
I have been trying to fix the overlapping of the text in the the li when zooming in but i am unable to find a solution here is the link to JSFiddle.
if anyone is able to help me i will be gladly appreciated.
What I've updated:
moved hyperlinks inside listItems
removed float:right inside cells
added min-width to first cell of every column
removed width attribute to seconds cells
CSS
a {
text-decoration: none;
}
table {
display: inline-block;
line-height: 10px;
padding: 0px;
margin: 0px;
vertical-align: middle;
}
td {
height: 20px;
}
ul {
padding: 0px;
min-width: 700px;
margin: 0px;
overflow: hidden;
}
img {
vertical-align: middle;
margin-left: 5px;
}
#main_forums li:hover {
background: #EEE;
border: 1px solid #EEE;
border-radius: 4px;
}
#main_forums .main_forum_container li {
border: 1px solid #FFF;
clear: both;
border-radius: 4px;
display: block;
min-height: 50px;
height: 50px;
min-width: 900px;
padding-bottom: 10px;
}
#main_forums {
}
.sub_description {
min-width:300px;
}
#main_forums .main_forum {
background: #880000;
margin-top: 10px;
border: 1px solid #800;
border-radius: 4px;
}
.main_forum_header {
color: #FFF;
font-size: 20px;
font-weight: bold;
}
.main_forum_container {
background: #FFF;
color: #800;
border: 4px solid #800;
padding: 10px;
}
HTML
<div id="main_forums">
<div class="main_forum">
<div class="main_forum_header">
<img src="images/programming.png" height="70" width="70">
<span class="main_forum_title">Programming</span>
</div>
<div class="main_forum_container">
<ul>
<li>
<a href="?p=forums&forum_id=2&sub_id=1">
<img src="images/php.png" height="60" width="60">
<table border="1">
<tbody>
<tr>
<td class="sub_description" >
<span>PHP - Web Programming</span>
</td>
<td style="margin-right: 0px;">Posts: 12011</td>
</tr>
<tr>
<td class="sub_description" style="font-size: 12px;" >PHP web applications.</td>
<td>Views: 12012311</td>
</tr>
</tbody>
</table>
</a>
</li>
<li>
<a href="?p=forums&forum_id=2&sub_id=2">
<img src="images/python.png" height="60" width="60" />
<table>
<tbody>
<tr>
<td class="sub_description" >
<span>Python - Application Programming</span>
</td>
<td style="margin-right: 0px;">Posts: 12011</td>
</tr>
<tr>
<td class="sub_description" style="font-size: 12px;" >Python Application programming</td>
<td>Views: 12012311</td>
</tr>
</tbody>
</table>
</a>
</li>
</ul>
</div>
</div>
<div class="main_forum">
<div class="main_forum_header">
<img src="images/web_developing.png" height="70" width="70" />
<span class="main_forum_title">Web Developing</span>
</div>
<div class="main_forum_container">
<ul>
<li>
<a href="?p=forums&forum_id=1&sub_id=4">
<img src="images/css.png" height="60" width="60" />
<table>
<tbody>
<tr>
<td class="sub_description">
<span>CSS</span>
</td>
<td style="margin-right: 0px;">Posts: 12011
</td>
</tr>
<tr>
<td class="sub_description" style="font-size: 12px;" >Cascading Style Sheets</td>
<td>Views: 12012311</td>
</tr>
</tbody>
</table>
</a>
</li>
<li>
<a href="?p=forums&forum_id=1&sub_id=3">
<img src="images/html.png" height="60" width="60" />
<table>
<tbody>
<tr>
<td class="sub_description">
<span>HTML</span>
</td>
<td style="margin-right: 0px;">Posts: 12011</td>
</tr>
<tr>
<td class="sub_description" style="font-size: 12px;" >HyperText Markup Language</td>
<td>Views: 12012311</td>
</tr>
</tbody>
</table>
</a>
</li>
</ul>
</div>
</div>
</div>
Is there a reason for the tables? The first thing I would do is remove the tables. In fact none of your HTML is semantic. You have tables inside of li tags and li tags surrounded by hyperlinks.
<ul>
<li>
<a href="?p=forums&forum_id=2&sub_id=1">
<img src="images/php.png" height="60" width="60">
<span>PHP - Web Programming</span>
Posts: 12011
PHP web applications.
Views: 12012311
</a>
</li>
<li>
<a href="?p=forums&forum_id=2&sub_id=2">
<img src="images/python.png" height="60" width="60">
<span>Python - Application Programming</span>
Posts: 12011
Python Application programming
Views: 12012311
</a>
</li>
</ul>
http://jsfiddle.net/pLy92/
See how that already cleans things up? These are all in-line elements so they line up.
Remove the slash() in that <a href="?p=forums&forum_id=1&sub_id=4">\