I want my html content to be center aligned, while maintaining the column structure of id game-inst
please feel free to edit my css code, waiting for your help, thanks
#score-container {
display: block;
width: 100%;
height: 100%;
text-align: center;
background-color: #1B2631;
color: #ffffff;
}
.key {
width: 40%;
display: inline-block;
}
.instruction {
display: inline-block;
width: 40%;
text-align: left;
}
#my-score,
#high-score,
#game-inst {
font-size: 1.25em;
padding: 0px 10px;
line-height: 1;
}
<div id="score-container">
<div id="game-inst">
<div class="key">Key 4:</div>
<div class="instruction">Move UP</div>
<div class="key">Key 6:</div>
<div class="instruction">Move DOWN</div>
<div class="key">Key 5:</div>
<div class="instruction">PLAY/PAUSE</div>
</div>
<p id="my-score">123</p>
<p id="high-score">786</p>
</div>
I believe this is what you want.
#score-container {
top: 100px;
display: block;
position: relative;
left: 0;
width: 100%;
height: 100%;
text-align: center;
z-index: 10;
}
.key {
width: 30%;
display: inline-block;
float: left;
}
.instruction {
width: 70%;
display: inline-block;
float: left;
}
#score-box {
position: relative;
width: 300px;
margin-left: auto;
margin-right: auto;
padding: 0;
}
#game-inst:after {
content: ".";
visibility: hidden;
display: block;
height: 0;
clear: both;
}
#my-score,
#high-score,
#game-inst {
font-size: 1.25em;
padding: 0px 10px;
line-height: 1;
text-align: left;
}
#score-box p {
width: 42%;
display: inline-block;
text-align: left;
border: solid 1px silver;
}
<div id="score-container">
<div id="score-box">
<div id="game-inst">
<div class="key">Key 4:</div>
<div class="instruction">Move UP</div>
<div class="key">Key 6:</div>
<div class="instruction">Move DOWN</div>
<div class="key">Key 5:</div>
<div class="instruction">PLAY/PAUSE</div>
</div>
<p id="my-score">123</p>
<p id="high-score">786</p>
</div>
</div>
Note the changes in .key, .instruction, #game-inst and the addition of #game-inst:after
#game-inst:after {
content: ".";
visibility: hidden;
display: block;
height: 0;
clear: both;
}
Which clears the floats added to the key and instruction classes.
Related
I know a lot of people asked that already but nothing seems to work. I want my footer to be on the bottom of the page. So far it is on the bottom of the screen, but if the page is bigger and you need to scroll, it just sticks there and stays in the middle. If I put position: fixed the footer scrolls with you. I want it to be at the VERY BOTTOM of the page, though, so you have to scroll down to see it in the first place, if the page is too big.
I tried several different wrappers and pushers but nothing seems to work.
You should overthink your layout and read about the HTML box model.
I put all your elements in a wrapper which is position: relative, so the footer with position: absolute can align properly. Also I had to remove position: absolute of .pageframe:
.pagelist {
background-color: deeppink;
position: relative;
float: right;
width: 20%;
height: 70%;
overflow-y: scroll;
margin-right: 10px;
}
.pageimg {
position: relative;
float: left;
width: 100%;
min-height: 500px;
text-align: center;
display: flex;
align-items: center;
}
.pageimg img {
margin: 0 auto;
}
.pagetext {
position: relative;
float: left;
margin-top: 1%;
width: 100%;
text-align: center;
padding-bottom: 10px;
}
.pageframe {
/* position: absolute; */
width: 75%;
margin-left: 10px;
text-align: center;
}
.comiclist {
background-color: lightgrey;
padding-left: 5px;
width: 90%;
}
.floatbutt-right {
float: right;
}
.floatbutt-left {
float: left
}
.footer {
position: absolute;
width: 100%;
bottom: 0;
height: 30px;
background-color: lightgrey;
font-size: 12px;
color: grey;
}
.footer span {
float: right;
margin-top: 5px;
margin-right: 10px;
}
body,
html {
margin: 0;
padding: 0;
height: 100%;
}
.spacer {
width: 100%;
height: 95px;
}
.content {
height: 100%;
width: 100%;
margin-bottom: -30px;
/* Footer */
}
#wrapper {
min-width: 100%;
min-height: 100%;
display:inline-block;
position:relative;
}
<head lang="de">
<link rel="stylesheet" href="inc/layout.css">
<script src="inc/javascript.js"></script>
<meta charset="UTF-8" />
<title>komix.lit</title>
</head>
<body>
<div id="wrapper">
<div id="navbar">
<img class="logo" src="inc/logo.png" /> komix.lit
<button id="home" class="navbutt" onClick="location.href='home.php'">Home</button>
<button id="comics" class="navbutt" onClick="location.href='komix.php'">Komix</button>
<button id="login" class="navbutt" onClick="location.href='login.php'">Einloggen</button></div>
<div class="content">
<div class="spacer"></div>
<div class="pagelist">
<ul style="list-style-type: none;">
<li><a style='text-decoration: none; color: black;' href='pages.php?id=84'>Seite 1</a></li>
<li><a style='text-decoration: none; color: black;' href='pages.php?id=86'>Seite 2</a></li>
<li><a style='text-decoration: none; color: black;' href='pages.php?id=85'>Seite 3</a></li>
</ul>
</div>
<div class='pageframe'>
<div class='pageimg' style='height: 1024;'>
<img src='komix\19_03_18_10_21_31-12.jpg' alt='seite 1' style='max-width:100%' /> </div>
<div class='pagetext'>seite 1</div><button class='floatbutt-right' onClick="location.href='pages.php?id=86'">nächste Seite</button></div>
</div>
<div class="footer">
<span>text</span>
</div>
</div>
</body>
</html>
You can try this, hope this will help you
Remove min-height for pageimg class and content class then you will get your output.
.pagelist {
background-color: deeppink;
position: relative;
float: right;
width: 20%;
height: 70%;
overflow-y: scroll;
margin-right: 10px;
}
.pageimg {
position: relative;
float: left;
width: 100%;
/* min-height: 500px; */
text-align: center;
display: flex;
align-items: center;
}
.pageimg img {
margin: 0 auto;
}
.pagetext {
position: relative;
float: left;
margin-top: 1%;
width: 100%;
text-align: center;
padding-bottom: 10px;
}
.pageframe {
position: absolute;
width: 75%;
margin-left: 10px;
text-align: center;
}
.comiclist {
background-color: lightgrey;
padding-left: 5px;
width: 90%;
}
.floatbutt-right {
float: right;
}
.floatbutt-left {
float: left
}
.footer {
position: absolute;
width: 100%;
bottom: 0;
height: 30px;
background-color: lightgrey;
font-size: 12px;
color: grey;
}
.footer span {
float: right;
margin-top: 5px;
margin-right: 10px;
}
body,
html {
margin: 0;
padding: 0;
height: 100%;
}
.spacer {
width: 100%;
height: 95px;
}
.content {
width: 100%;
margin-bottom: -30px;
/* Footer */
}
<div id="navbar">
<img class="logo" src="inc/logo.png" />
komix.lit
<button id="home" class="navbutt" onClick="location.href='home.php'">Home</button>
<button id="comics" class="navbutt" onClick="location.href='komix.php'">Komix</button>
<button id="login" class="navbutt" onClick="location.href='login.php'">Einloggen</button></div>
<div class="content">
<div class="spacer"></div><div class="pagelist"><ul style="list-style-type: none;"><li><a style='text-decoration: none; color: black;' href='pages.php?id=84'>Seite 1</a></li><li><a style='text-decoration: none; color: black;' href='pages.php?id=86'>Seite 2</a></li><li><a style='text-decoration: none; color: black;' href='pages.php?id=85'>Seite 3</a></li></ul></div><div class='pageframe'><div class='pageimg' style='height: 1024;'>
<img src='komix\19_03_18_10_21_31-12.jpg'
alt='seite 1' style='max-width:100%'/> </div><div class='pagetext'>seite 1</div><button class='floatbutt-right' onClick="location.href='pages.php?id=86'">nächste Seite</button></div></div>
<div class="footer">
<span>text</span>
</div>
I've definitely never identified myself as a coder, which is why I need some help. I've tried & tried to get a grid of shapes with text overlayed to change to different text whenever the mouse is hovering over it - completely different text. I looked up before & after properties but still can't get it right because of the "grid" css.
I'm hoping to have "name" on the normal shape, and then other text on the hovered shape for more information. How would I go about doing this? I've supplied a fiddle to show everything.
http://jsfiddle.net/6c4v2ypv/3/
Thank you all tremendously for your help.
CSS
.grid {
width: 100%;
max-width: 900px;
margin: 0 auto;
background: #fff;
}
.grid::after {
content: "";
display: block;
clear: both;
}
.grid-item {
width: 21.833%;
padding-bottom: 21.833%;
overflow: hidden;
float: left;
background: #BBB;
transform: rotate(45deg);
margin: 5.5%;
margin-top: -11%;
}
.grid-item:nth-child(1),
.grid-item:nth-child(2),
.grid-item:nth-child(3) {
margin-top: 5%;
}
.grid-item:nth-child(5n+4) {
margin-left: 21.9%;
}
.grid-item:nth-child(5n+6) {
clear: left;
}
.grid-item:nth-child(5n+6):last-of-type {
margin-left: 38.25%;
}
.grid-item:hover {
background: #000;
}
.grid-inner {
box-sizing: border-box;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
transform: rotate(-45deg);
text-align: center;
padding-top: 40%;
font-size: 1em;
}
.grid-inner:hover a span {
display: none;
}
.grid-inner:hover:after {
box-sizing: border-box;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
transform: rotate(-45deg);
text-align: center;
padding-top: 40%;
font-size: 1em;
background-color: black;
}
Maybe so?
.grid {
width: 100%;
max-width: 900px;
margin: 0 auto;
background: #fff;
}
.grid::after {
content: "";
display: block;
clear: both;
}
.grid-item {
width: 21.833%;
padding-bottom: 21.833%;
overflow: hidden;
float: left;
background: #BBB;
transform: rotate(45deg);
margin: 5.5%;
margin-top: -11%;
}
.grid-item:nth-child(1),
.grid-item:nth-child(2),
.grid-item:nth-child(3) {
margin-top: 5%;
}
.grid-item:nth-child(5n+4) {
margin-left: 21.9%;
}
.grid-item:nth-child(5n+6) {
clear: left;
}
.grid-item:nth-child(5n+6):last-of-type {
margin-left: 38.25%;
}
.grid-item:hover {
background: #000;
}
.grid-inner {
box-sizing: border-box;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
transform: rotate(-45deg);
text-align: center;
padding-top: 40%;
font-size: 1em;
}
.grid-inner:hover a span {
display: none;
}
.grid-inner:hover:after {
box-sizing: border-box;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
transform: rotate(-45deg);
text-align: center;
padding-top: 40%;
font-size: 1em;
background-color: black;
}
.grid-inner-hover {
opacity: 0;
}
.grid-item:hover .grid-inner-hover {
opacity: 1;
color: #fff;
}
<div class="grid">
<div class="grid-item">
<div class="grid-inner">Name 1</div>
<div class="grid-inner grid-inner-hover">Name 1 Hover</div>
</div>
<div class="grid-item">
<div class="grid-inner">Name 2</div>
<div class="grid-inner grid-inner-hover">Name 2 Hover</div>
</div>
<div class="grid-item">
<div class="grid-inner">Name 3</div>
<div class="grid-inner grid-inner-hover">Name 3 Hover</div>
</div>
<div class="grid-item">
<div class="grid-inner">Name 4</div>
<div class="grid-inner grid-inner-hover">Name 4 Hover</div>
</div>
<div class="grid-item">
<div class="grid-inner">Name 5</div>
<div class="grid-inner grid-inner-hover">Name 5 Hover</div>
</div>
<div class="grid-item">
<div class="grid-inner">Name 6</div>
<div class="grid-inner grid-inner-hover">Name 6 Hover</div>
</div>
</div>
here's a simple example:
.item1:hover span, .item2:hover span{
display: none;
}
.item1:hover:after{
content: 'ADD';
}
.item2:hover:after{
content: 'Subtract';
}
<div class="item1">
<span >first</span>
</div>
<div class="item2">
<span>second</span>
</div>
You can also add something like this in your css:
.grid-inner:hover:after{
content:'hello';
color:#fff;
transform:rotate(0deg);
}
http://jsfiddle.net/6c4v2ypv/5/
I've been trying to get this postioning right for a long time, her's a sketch of that it's supposed to look like:
Here's the css that I got going:
.team1 {
margin-left: 9;
}
.team2 {
float: right;
right: 10;
position: relative;
}
.team1text{
float: left;
left: 150;
top:50;
position: relative;
}
.team2text{
float: right;
right: 150;
top:30;
position: relative;
}
.team1winlose{
float: left;
left: 150;
top:50;
position: relative;
}
.team2winlose{
float: right;
right: 150;
top:50;
position: relative;
}
.vs {
positon: relative;
top: 30;
float: right;
right: 50%;
}
But it now looks like this when I open the page:
With flexbox you could do like this
.wrapper {
display: flex;
}
.wrapper .logo {
flex: 0;
}
.wrapper > :not(.logo) {
flex: 1;
text-align: center;
word-break: break-all;
}
.wrapper :not(.logo) div {
font-size: 32px;
font-weight: bold;
}
.wrapper :not(.logo) span {
font-size: 16px;
}
.wrapper .separator {
flex: 0;
min-width: 70px;
}
<div class="wrapper">
<div class="logo">
<img src="http://placehold.it/150">
</div>
<div>
<div>Team 12345678</div>
<span>Wins/Losses</span>
</div>
<div class="separator">
<div>VS</div>
</div>
<div>
<div>Team 2</div>
<span>Wins/Losses</span>
</div>
<div class="logo">
<img src="http://placehold.it/150">
</div>
</div>
For older browsers, display: table
.wrapper {
display: table;
width: 100%;
}
.wrapper .logo {
display: table-cell;
width: 150px;
}
.wrapper > :not(.logo) {
display: table-cell;
width: 20%;
text-align: center;
vertical-align: top;
}
.wrapper :not(.logo) div {
font-size: 32px;
font-weight: bold;
}
.wrapper :not(.logo) span {
font-size: 16px;
}
<div class="wrapper">
<div class="logo">
<img src="http://placehold.it/150">
</div>
<div>
<div>Team 1</div>
<span>Wins/Losses</span>
</div>
<div>
<div>VS</div>
</div>
<div>
<div>Team 2</div>
<span>Wins/Losses</span>
</div>
<div class="logo">
<img src="http://placehold.it/150">
</div>
</div>
So I have a silly question, how do I get my divs on the right side? I have main content but I need to set up four divs on the right side. It looks like this and I need to add div1 - 4. Am I supposed to add width:100%; float: left in .main_container?
Question #2 - I would like to group main_info1 - 3 under one div like main so that I could use .main in css with max-width: 900px; overflow: hidden; margin-left: 20px; attributes for all divs without the need for repeating but when I do that main_info2 jumps up and ignores main_info1 lists. Thanks.
HTML:
<div class="main_container">
<div class="title_container">
<h1>Title</h1>
</div>
<aside>
<div class="small_blocks">
<div class="block1">
<span>Text</span>
</div>
<div class="block2">
<span>Text</span>
</div>
</div>
</aside>
<div class="content clearfix">
<div class="image1">
<img src="img/img1.jpg">
</div>
<div class="image2">
<img src="img/img2.jpg">
</div>
</div>
<div class="main_info">
<h2>Title</h2>
<p>Text</p>
</div>
<div class="main_info2 clearfix">
<h2>Title</h2>
<ul>
<li>
<p>Text</p>
</li>
</ul>
</div>
<div class="main_info3 clearfix">
<h2>Title</h2>
<p>Text</p>
</div>
</div>
CSS:
.main_container {
width: 1360px;
margin: 0 auto;
background: url("../img/bg.jpg") left top no-repeat;
background-color: #0c0334;
}
.title_container {
display: table;
}
.title_container h1 {
float: left;
display: table-cell;
vertical-align: top;
margin-top: 50px;
margin-left: 20px;
line-height: 66px;
}
.small_blocks {
min-width: 900px;
overflow: hidden;
}
.small_blocks div {
height: 55px;
margin-top: 30px;
}
.small_blocks .block1 {
float: left;
margin-left: 20px;
background: #390b5d;
width: 595px;
line-height: 52px;
}
.small_blocks .block1 span {
font-size: 30px;
padding-left: 20px;
font-weight: 100;
}
.small_blocks .block2 {
float: left;
width: 285px;
background: #e26c34;
padding-left: 20px;
line-height: 52px;
vertical-align: middle;
}
.small_blocks .block2 span {
font-size: 30px;
padding-left: 10px;
font-weight: 100;
vertical-align: middle;
display: inline-block;
}
.clearfix:after {
content: "";
visibility: hidden;
display: block;
height: 0;
clear: both;
}
.content {
width: 900px;
height: 377px;
overflow: hidden;
margin: 20px 0 0 20px;
}
.content .image1 {
float: left;
width: 268px;
}
.content .image2 {
float: left;
margin-left: 10px;
width:100%;
max-width: 622px;
}
.main_info {
max-width: 900px;
overflow: hidden;
margin-top: 60px;
margin-left: 20px;
}
.main_info h2 {
height: 34px;
border-bottom: 1px solid #390b5d;
}
.main_info2 {
max-width: 900px;
overflow: hidden;
margin: 60px 0px 0px 20px;
background: #110321;
}
.main_info2 h2 {
background: #390b5d;
min-height: 55px;
width: 880px;
padding-left: 20px;
height: 34px;
color: #fff;
line-height: 52px;
}
.main_info3 {
max-width: 900px;
overflow: hidden;
margin: 60px 0px 0px 20px;
background: #390b5d;
}
.main_info3 h2 {
min-height: 55px;
width: 880px;
padding-left: 20px;
height: 34px;
color: #fff;
line-height: 52px;
}
I think you are a newbie. You should work hard to master in HTML and CSS. :)
However, here is a solution. Please inspect them closely. Hopefully you will get your answers.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
img {
display: block;
}
.clearfix:after {
content: "";
visibility: hidden;
display: block;
height: 0;
clear: both;
}
.wrapper {
min-width: 1000px;
max-width: 1360px;
margin: 0 auto;
padding: 0 20px;
}
.title_container {
padding-top: 50px 0 30px;
}
.title_container h1 {
line-height: 66px;
}
.small_blocks {
height: 55px;
overflow: hidden;
margin-bottom: 20px;
font-size: 30px;
font-weight: 100;
line-height: 52px;
color: #fff;
}
.small_blocks > div {
height: inherit;
float: left;
padding-left: 20px;
}
.small_blocks .block1 {
background: #390b5d;
width: 66.111111%;
}
.small_blocks .block2 {
width: 33.888889%;
background: #e26c34;
}
.content {
/*height: 377px;*/
overflow: hidden;
margin-bottom: 60px;
}
.content > div img {
width: 100%;
height: auto;
}
.content .image1 {
float: left;
width: 29.777778%;
}
.content .image2 {
float: left;
width: 70.222222%;
padding-left: 10px;
}
.main_container {
width: 68.181818%;
float: left;
}
.main_info {
margin-bottom: 60px;
background: #d7d7d7;
}
.main_info .head {
padding-left: 20px;
background: #000;
color: #fff;
}
.main_info h2 {
height: 34px;
line-height: 34px;
}
.main_info .body {
padding: 20px;
}
.sidebar {
width: 31.818182%;
padding-left: 20px;
float: right;
}
.sidebar_block {
min-height: 150px;
margin-bottom: 20px;
padding: 20px;
background: #000;
color: #fff;
}
<div class="wrapper">
<header class="title_container">
<h1>Title</h1>
</header>
<main class="main_container">
<div class="small_blocks">
<div class="block1">
<span>Block 1</span>
</div>
<div class="block2">
<span>Block 2</span>
</div>
</div>
<div class="content clearfix">
<div class="image1">
<img src="http://dummyimage.com/268x377/000/fff.jpg&text=image1">
</div>
<div class="image2">
<img src="http://dummyimage.com/622x377/000/fff.jpg&text=image2">
</div>
</div>
<section class="main_info">
<div class="head">
<h2>Main Info-1 h2</h2>
</div>
<div class="body">
Main info 1
</div>
</section>
<section class="main_info">
<div class="head">
<h2>Main Info-2 h2</h2>
</div>
<div class="body">
Main info 2
</div>
</section>
<section class="main_info">
<div class="head">
<h2>Main Info-3 h2</h2>
</div>
<div class="body">
Main info 3
</div>
</section>
</main>
<aside class="sidebar">
<section class="sidebar_block">Div 1</section>
<section class="sidebar_block">Div 2</section>
<section class="sidebar_block">Div 3</section>
<section class="sidebar_block">Div 4</section>
</aside>
</div>
Regarding the questions in your comment:
Actually float works. As you use a fixed width width: 420px;, probably there has no enough space for the second ul to accommodate it in a single row. Use width: 50%; or below and see the changes. Or, you can check it in a wider screen, like, 1360px resolution.
Yes, for smaller devices.
This is a basic example. I used percentage values for the column width. So columns may become very narrower in smaller devices. To prevent that, I used min-width: 1000px for .wrapper. This will prevent narrower column width, but cause a horizontal scroll-bar in smaller devices.
Can anyone help me figure out what i'm doing wrong?
I want to insert the text inside "servicesTitle"in the middle of the image.
I have tried position, top, vertical align..and can't figure out what i'm doing wrong
<div class="services">
<p id="titleServices">Our Services</p>
<div class="servicesImages">
<div class="servicesImagesLeft">
<div id="cultureNews">
<div class="servicesTitle">Culture News</div>
<img src="/www/assets/newImages/services/190x136/Culture News1.jpg">
</div>
<div id="meetingPoint">
<div class="servicesTitle">Meeting Point</div>
<img src="/www/assets/newImages/services/190x136/MeetingPoint1.jpg">
</div>
</div>
<div class="servicesImagesCenter">
<div id="gallery">
<img src="/www/assets/newImages/services/460x330/Gallery.jpg">
<div class="servicesTitleActive">Gallery</div>
</div>
</div>
<div class="servicesImagesRight">
<div id="profile">
<div class="servicesTitle">Profile</div>
<img src="/www/assets/newImages/services/190x136/MeetingPoint1.jpg">
</div>
<div id="invitation">
<div class="servicesTitle">Invitation
<img src="/www/assets/newImages/services/190x136/MeetingPoint1.jpg">
</div>
</div>
</div>
</div>
</div>
CSS:
html, body {
margin: 0;
padding: 0;
}
#clear {
clear: both;
}
.services {
height: 100%;
margin-left: 7.5%;
margin-right: 7.5%;
}
.services p#titleServices {
text-align: center;
color: #ffffff;
padding-top: 40px;
}
.services .servicesImages {
border: 1px solid #fff;
margin-top: 65px;
text-align:center;
}
.services .servicesImages .servicesImagesLeft {
width: 190px;
height: 136px;
margin-top: 20px;
float:left;
position: relative;
}
.services .servicesImages .servicesImagesCenter {
display: inline-block;
margin: 0 auto;
width: 460px;
height: 330px;
}
.services .servicesImages .servicesImagesRight {
width: 190px;
height: 136px;
margin-top: 20px;
float:right;
position: relative;
}
.servicesImagesLeft #cultureNews {
width: 100%;
height: 100%;
}
.servicesImagesLeft #meetingPoint {
width: 100%;
height: 100%;
margin-top: 10px;
}
.servicesImagesCenter #gallery {
width: 100%;
height: 100%;
}
.servicesImagesRight #profile {
width: 100%;
height: 100%;
}
.servicesImagesRight #invitation {
width: 100%;
height: 100%;
margin-top: 10px;
}
.servicesImagesLeft img, .servicesImagesRight img {
opacity: 0.7;
}
.servicesTitleActive {
text-align: center;
margin-top: 25px;
color: #fff;
}
.servicesTitle {
color: #fff;
}
.services p#titleServices {
Needs to be:
.services .servicesTitle {
.servicesTitle {
color: #fff;
width: 100%;
height:100%;
position: absolute;
top:60%;
left:auto;
z-index:2;
}
http://jsfiddle.net/uHY7C/