Hi I've written some code where I have create two divs wrapped inside another div. I have then create a league table and floated it to the right hand side. I have made the 2 divs on the left hand side small enough for the league to go alongside them however it doesn't seem to move upwards it stay in it position below the 2 divs. Also when I would like my 2 divs on the left hand side to adjust to whatever is inside my them. At the moment if I have one line inside the div its height is still fitted for 10 lines.
Should I use flex box for this? Any help would be much appreciated
`
<li id="et"> England
<ul>
<li>Premiership
</li>
<li>Championship
</li>
<li>League 1
</li>
<li>League 2
</li>
</ul>
</li>
<li id="et"> France
<ul>
<li>Ligue 1
</li>
</ul>
</li>
<li id="et"> Germany
<ul>
<li>Bundesliga
</li>
</ul>
</li>
<li id="et"> Italy
<ul>
<li>Serie A
</li>
</ul>
</li>
<li id="et"> Spain
<ul>
<li>La Liga
</li>
</ul>
</li>
</ul>
</div>
<!-- Nav wrapper end -->
`https://jsfiddle.net/e2cmhrec/
jsFiddle demo
You .wrap has
width:70%;
margin-left:3%;
with some elementary calculation you have remaining: 27%.
But than suddenly you decided to make your right floated #sidebar
width: 30%
Even if you used erratically width:30% than suddenly your table inside the sidebar has:
width:120%;
Don't forget to float:left your .wrap if you want to accomodate your #sidebar to the right float.
Your .wrap has display: table; and you used for the first child display:table-cell. What about the second child?
Also why use float:left on a table-cell element?
To improve your table.grid look'n'feel you might want to use:
border-collapse:collapse;
also where you have yoru injuries and suspension cells, use for the display:table element also:
border-spacing: 16px; /* learn CSS rules */
border-collapse: separate; /* learn CSS rules */
I've also seen a funny thing, you named a class .ArsStand for Arsenal that gives a red border... top and apparently not the bottom one, so you decided to add the same class to the team underneath... No. 1. try not to name classes related to a variable page content. 2. create your special classes after the common element rules (in order to overwrite them.)
Don't add height to tables... one day you might have more data and question why it's all so squished. Rather add vertical padding to your td elements.
You cannot have duplicate ID elements in a single page! id="headinj"
Related
In the picture its shown that the 2 sets of list aren't at the same height or width. I am new to html/ccs and I cant figure how to fix it.
I've already tried to chance the margin to 0 instead of auto because i though it would solve the problem.
The line of code I've been told my mistake is placed in is this:
ul.lister {
display: inline-block;
text-align: left;
margin-top: auto;
margin-buttom: auto;
}
<ul class="lister">
<p><big>Jeg ønsker mig... (snacks edition)</big></p>
<li> FaxeKondi (gerne i ramme).</li>
<li> Saltede peanuts </li>
<li> Corny Müslibar m. banan og chokolade</li>
<li> MælkeChokolade</li>
<li> HvidChokolade</li>
</ul>
<ul class="lister">
<p><big>Jeg ønsker mig... (gavekort edition)</big></p>
<li> Sport24</li>
<li> Normal</li>
<li> Løvbjerg</p>
<li> Føtex</li>
<li> Lidl</li>
<li> Aldi</li>
<li> MacDonals</li>
<li> Netto</li>
</ul>
thanks in advance and sorry if there is some words that have been misspelled
First, you've got some errors in your markup: The only permitted content inside ul elements are the list item element (<li>). Inside list items you could put a <p>, but I would recommend to put the list heading outside the list for readability.
Then in your CSS, you've got margin-buttom, which should be margin-bottom.
Finally, there are several ways to put elements side by side in CSS and I will not tell you how to do that, but take a look at this article to get some ideas how you could solve it.
The two items aren't equal width or height because they'll only take up as much space as needed and that's dependent on the content width and height.
If you wrap each list item in a container and use display:flex then that'll make them appear side by side. You can then use flex-basis in the child elements to make them equal width. Finally putting paragraphs in unordered lists isn't great so I've separated them out and wrapped that block in divs of their own that can be sized appropriately.
CSS tricks is a good starting point for flexbox
There's also some syntax errors that I've corrected.
Also note that the big tag isn't supported in html5
See below
.container {
display: flex;
}
.lister {
flex-basis: 50%;
text-align: left;
margin-top: auto;
margin-bottom: auto;
}
<div class="container">
<div class="lister">
<p><big>Jeg ønsker mig... (snacks edition)</big></p>
<ul>
<li> FaxeKondi (gerne i ramme).</li>
<li> Saltede peanuts </li>
<li> Corny Müslibar m. banan og chokolade</li>
<li> MælkeChokolade</li>
<li> HvidChokolade</li>
</ul>
</div>
<div class="lister">
<p><big>Jeg ønsker mig... (gavekort edition)</big></p>
<ul>
<li> Sport24</li>
<li> Normal</li>
<li> Løvbjerg</li>
<li> Føtex</li>
<li> Lidl</li>
<li> Aldi</li>
<li> MacDonals</li>
<li> Netto</li>
</ul>
</div>
</div>
I basically want to keep the nav with all of its contents at the top of the HTML, but have it moved to the bottom of the page with CSS as I am doing mobile-first approach and want the navigation to appear at the top when I resize it to tablet or laptop. I tried using minus with bottom tag but it takes forever to get it to the bottom and does not seem to be the most efficient way to do it. Is the only way to move the context to the bottom of the page is to put it at the bottom of HTML file or is there a completely different way I should approach this?
This is what I have at the moment:
I want to move the underlined links to the bottom, my code:
#topnavigationmenu li {
display: inline-block;
list-style-type: none;
font-size: 3rem;
padding: 10px;
}
<div id="mainpage">
<nav id="topnavigationmenu">
<ul>
<li> example </li>
<li> example </li>
<li> example </li>
</ul>
</nav>
The easiest solution: You can create two instances of <nav> and show one on mobile and on desktop using media queries.
Possibly better solution: You can use Flexbox (and even CSS Grid I guess) to change the order, so let's say inside the mainpage div you have two sections the nav and a div with your page content:
<nav id="topnavigationmenu">
<ul>
<li> example </li>
<li> example </li>
<li> example </li>
</ul>
</nav>
<div class="page-content">
<!-- Content here -->
</div>
You can add display:flex; to mainpage and manipulate the order these appear on mobile vs desktop/tablet using media queries.
I'd suggest checking these articles out:
Ordering Flex Items
A Complete guide to Flexbox
Weird problem that <ol> list item number isn't aligned with its content. See live page or screenshots: 1, 2
See the line numbers of the ordered list isn't aligned with its content. They are all down below when the screen is wide and up in the air when the screen is narrow.
Thought it's something wrong with the CSS since both Chrome and Firefox render the list this way, but didn't find any weird styles at all in the stylesheets. Is this normal behavior of HTML5 <ol>? How can I make it the item numbers are aligned to the top line of its corresponding content, both wide and narrow screen?
This is because you have applied display:inline-block to the <a> tags. Just apply display:block to the <a> tags
Stack Snippet
a {
display: block;
margin-bottom: 10px;
}
<ol>
<li> <a>http://n3.datasn.io/data/api/v1/n3_lyz/cars_and_powersports_vehicle_and_motorcycle_and_boat_14/atv/list/?app=html-bunker</a>
</li>
<li> <a>http://n3.datasn.io/data/api/v1/n3_lyz/cars_and_powersports_vehicle_and_motorcycle_and_boat_14/atv/list/?app=html-bunker</a>
</li>
<li> <a>http://n3.datasn.io/data/api/v1/n3_lyz/cars_and_powersports_vehicle_and_motorcycle_and_boat_14/atv/list/?app=html-bunker</a>
</li>
<li> <a>http://n3.datasn.io/data/api/v1/n3_lyz/cars_and_powersports_vehicle_and_motorcycle_and_boat_14/atv/list/?app=html-bunker</a>
</li>
</ol>
It has to do with the CSS rule for .links-4 a. It sets display: inline-block;. If you change it to display: inline, it'll be fine.
I want to put some space between some horizontally laid out list items, should I use or padding-left to separate them?
  example:
<ul class="menu">
<li class="menu_item">Option 1 </li>
<li class="menu_item">Option 2</li>
</ul>
padding-left example:
<ul class="menu">
<li class="menu_item">Option 1</li>
<li class="menu_item">Option 2</li>
</ul>
.menu li.menu_item { padding-left: 10px; }
Simple answer. Use padding-left it's easier to maintain, change and it's more customizable. As suggested above you might even want to use margin instead of padding this is usually necessary to separate items with a background-color.
I'll show an example just give me a second to make one.
Edit:
Here's a fiddle. I decided to just show you full screen since you already know the html and css.
Notice how the background-color is seperated with margins, but not with padding or  . Margin is often useful for that reason, but sometimes you want the background color in the spacing. You can use both margin and padding to get the spacing you want.
The reason why margin works that way and padding doesn't is because of the box-model. More about the box-model here.
Padding is definitly the best way to do that.
In fact it will be more easy for you later, to customize your list...
Imagine that there is not only 2-3 colums or row in your list but 100 etc...
Take a list like this:
<ul class="menu">
<li> Option 1 </li>
<li> Option 2 </li>
</ul>
The css part would looks like this:
.menu
{
//Your style..
}
.menu li
{
padding-left: 5px; //As you wants...
}
Refrain from using
padding-left is the right option.
Alternatively you can use margin-left
As you are creating a menu, I would suggest (based on my past experience) using margin-left for list being used for menu items. Gives more flexibility and cleanliness.
I'm new to programming and I'm trying to build a website with various links in the same line. I'm using div so I got them all on the same block. The problem is that when I put all the links on float:left, the background color dissappears, but when I put the last link with float:center it shows the background as I want it.
Can anyone help me? Thanks in advance
This is what I'm using:
<div id="links" style="width:1250;height:450;background-color:#000000;text-align:center">
<ul type="none">
<li style="float:left;margin-right:100px;text-align:center">
Nosotros
</li>
<li style="float:left;margin-right:100px">
Desafío UNIMET
</li>
<li style="float:left;margin-right:100px">
Patrocinantes
</li>
<li style="float:left;margin-right:100px">
Contacto
</li>
</ul></div>
There is no such thing as float: center only left, right, none, and inherit. But the reason the parent container bg color is not showing is because when you float an element it no longer takes up space in its parent.
Either give your parent container a height (and specify pixels or some other unit of measure which you aren't doing now), or as a hack you can give the parent: "overflow: hidden;" css property.
Good luck in your learnings! Time and passion will get you everwhere!
EDIT: I highly recommend you get the book CSS Mastery by Andy Budd. It will teach you this and a lot more.
You had not given the unit to width, and height. Make it to px or em or as per what you need and it will work.
<div id="links" style="width:1250px;height:450px;background-color:#000000;text-align:center">
<ul type="none">
<li style="float:left;margin-right:100px;text-align:center">
Nosotros
</li>
<li style="float:left;margin-right:100px">
Desafío UNIMET
</li>
<li style="float:left;margin-right:100px">
Patrocinantes
</li>
<li style="float:left;margin-right:100px">
Contacto
</li>
</ul></div>
Try this http://jsfiddle.net/sLEYs/
Secondly, there is no such value center for float. http://www.w3schools.com/css/css_float.asp