Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to
LinuxQuestions.org , a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free.
Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please
contact us . If you need to reset your password,
click here .
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a
virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month.
Click here for more info.
11-01-2016, 09:25 AM
#16
Member
Registered: Mar 2011
Location: Winston-Salem, NC
Distribution: Fedora, CentOS, Linux Mint
Posts: 259
Original Poster
Rep:
grail,
You are exactly right.
The change I made was changing the .box class from:
Code:
.box {
width: 50px;
height: 50px;
display: inline-block;
padding: 0;
margin: 0;
border: collapse;
float: left;
font-size: 12;
column-width: 0;
z-index: -1;
}
to:
Code:
.box {
width: 50px;
height: 50px;
padding: 0;
margin: 0;
float: left;
}
That worked for the first row. My first issue is that I don't know why. I tell you, I had it that way to begin with before I ended up where I started the thread.
Now, to look at astogeek's code and see if I can solve problem two and mark the thread as solved, and go find my next problem.
Quote:
Originally Posted by
grail
Ultimately the question has changed seeing as you solved your original problem, however, you have not advised what it was you changed that made the difference? Remember, others will find
your question and would like to know what changed without having to go through the code and miss the subtlety, especially when you have now changed the code to perform an additional task (like more rows)
11-01-2016, 10:20 AM
#17
Member
Registered: Mar 2011
Location: Winston-Salem, NC
Distribution: Fedora, CentOS, Linux Mint
Posts: 259
Original Poster
Rep:
Maestro, drum roll, please.
Aaaaaannnnnd, done.
The true underlying issue is that I don't fully understand the concepts of CSS yet. That is fixable, but is going to take time, and I expect patience from the lot of you.
Thanks again, for the help.
This is where I ended up.
Code:
<!--<!DOCTYPE html>-->
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>div test</title>
<style>
body {
background-color: #AAAAAA;
}
.box {
width: 50px;
height: 50px;
padding: 0;
margin: 0;
float: left;
}
.blackSquare {
background: black;
}
.whiteSquare {
background: white;
}
.newrow {
clear: both;
}
</style>
</head>
<body>
<div class="box blackSquare"></div><div class="box whiteSquare"></div><div class="box blackSquare"></div><div class="box whiteSquare"></div><div class="box blackSquare"></div><div class="box whiteSquare"></div><div class="box blackSquare"></div><div class="box whiteSquare"></div>
<div class="box whiteSquare newrow"></div><div class="box blackSquare"></div><div class="box whiteSquare"></div><div class="box blackSquare"></div><div class="box whiteSquare"></div><div class="box blackSquare"></div> <div class="box whiteSquare "></div><div class="box blackSquare"></div>
<div class="box blackSquare newrow"></div><div class="box whiteSquare"></div><div class="box blackSquare"></div><div class="box whiteSquare"></div><div class="box blackSquare"></div><div class="box whiteSquare"></div><div class="box blackSquare"></div><div class="box whiteSquare"></div>
<div class="box whiteSquare newrow"></div><div class="box blackSquare"></div><div class="box whiteSquare"></div><div class="box blackSquare"></div><div class="box whiteSquare"></div><div class="box blackSquare"></div> <div class="box whiteSquare "></div><div class="box blackSquare"></div>
<div class="box blackSquare newrow"></div><div class="box whiteSquare"></div><div class="box blackSquare"></div><div class="box whiteSquare"></div><div class="box blackSquare"></div><div class="box whiteSquare"></div><div class="box blackSquare"></div><div class="box whiteSquare"></div>
<div class="box whiteSquare newrow"></div><div class="box blackSquare"></div><div class="box whiteSquare"></div><div class="box blackSquare"></div><div class="box whiteSquare"></div><div class="box blackSquare"></div> <div class="box whiteSquare "></div><div class="box blackSquare"></div>
<div class="box blackSquare newrow"></div><div class="box whiteSquare"></div><div class="box blackSquare"></div><div class="box whiteSquare"></div><div class="box blackSquare"></div><div class="box whiteSquare"></div><div class="box blackSquare"></div><div class="box whiteSquare"></div>
<div class="box whiteSquare newrow"></div><div class="box blackSquare"></div><div class="box whiteSquare"></div><div class="box blackSquare"></div><div class="box whiteSquare"></div><div class="box blackSquare"></div> <div class="box whiteSquare "></div><div class="box blackSquare"></div>
</body>
</html>
I have attached the final result.
11-01-2016, 01:45 PM
#18
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552
Another way, using li's and nth-child() Selector
http://www.w3schools.com/cssref/sel_nth-child.asp
Edit: of course, the easiest way would be to use table, if religion permits
Code:
<!--<!DOCTYPE html>-->
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>div test</title>
<style>
body {
background-color: #AAAAAA;
}
#board {
padding:0;
margin:0;
}
#board ul {
list-style:none;
clear:left;
padding:0;
margin:0;
}
#board ul li {
width: 50px;
height: 50px;
float: left;
background: black;
}
#board ul:nth-child(odd) li:nth-child(even),
#board ul:nth-child(even) li:nth-child(odd)
{
background: white;
}
</style>
</head>
<body>
<div id="board">
<ul><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>
<ul><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>
<ul><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>
<ul><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>
<ul><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>
<ul><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>
<ul><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>
<ul><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>
</div>
</body>
</html>
Last edited by keefaz; 11-01-2016 at 02:47 PM .
11-01-2016, 09:09 PM
#19
LQ Guru
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,008
11-02-2016, 08:29 AM
#20
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552
Using floating p's and br's, it is possible to switch background color without taking care of the even/odd rows change
Code:
<!--<!DOCTYPE html>-->
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>Checkboard test</title>
<style>
body {
background-color: #AAAAAA;
}
#board {
padding:0;
margin:0;
}
#board p {
width: 50px;
height: 50px;
float: left;
background: black;
margin:0;
}
#board br {
clear: left;
}
#board :nth-child(even) {
background: white;
}
</style>
</head>
<body>
<div id="board">
<p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><br>
<p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><br>
<p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><br>
<p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><br>
<p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><br>
<p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><br>
<p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><br>
<p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><br>
</div>
</body>
</html>
11-02-2016, 08:06 PM
#21
Member
Registered: Mar 2011
Location: Winston-Salem, NC
Distribution: Fedora, CentOS, Linux Mint
Posts: 259
Original Poster
Rep:
See, this is what I'm talking about. I don't yet know my way around. I'm going to, however.
---------------------
Quote:
Originally Posted by
keefaz
Another way, using li's and nth-child() Selector
http://www.w3schools.com/cssref/sel_nth-child.asp
Edit: of course, the easiest way would be to use table, if religion permits
Code:
<!--<!DOCTYPE html>-->
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>div test</title>
<style>
body {
background-color: #AAAAAA;
}
#board {
padding:0;
margin:0;
}
#board ul {
list-style:none;
clear:left;
padding:0;
margin:0;
}
#board ul li {
width: 50px;
height: 50px;
float: left;
background: black;
}
#board ul:nth-child(odd) li:nth-child(even),
#board ul:nth-child(even) li:nth-child(odd)
{
background: white;
}
</style>
</head>
<body>
<div id="board">
<ul><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>
<ul><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>
<ul><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>
<ul><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>
<ul><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>
<ul><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>
<ul><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>
<ul><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>
</div>
</body>
</html>
------------------
Quote:
Originally Posted by
grail
All times are GMT -5. The time now is 09:53 PM .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know .
Latest Threads
LQ News