I have this theme: https://www.similaricons.com/demos/milano/about.html, And I want to reduce the persons shown below the "Be Creative." block down to 2. Now, when I remove two persons, the remaining stick to the left side. I don't want that. Instead, I want them both to be in the center when I have an lg resolution. Can you help?
What you could do is place the divs in single row in a table. Check out my example below:
#tbl_container {
background: red;
width: 100%;
}
#tbl_container > table {
margin-left: auto;
margin-right: auto;
}
.pic_block {
background: black;
width: 80px;
height: 100px;
float: left;
margin: 5px;
}
<!DOCTYPE html>
<html>
<body>
<div id="tbl_container">
<table>
<tr>
<td>
<div class="pic_block"></div>
<div class="pic_block"></div>
<div class="pic_block"></div>
<div class="pic_block"></div>
</td>
</tr>
</table>
</div>
</body>
</html>
Related
I'm creating my first basic website using html and css, it's just a simple custom link tree type website where my socials will be laid out on the screen. I'm trying to create 2 columns with 3 rows. Every element in the row is spaced super far away from each other and I can't figure out how to fix this.
HTML Code:
<body class="body">
<div class="container">
<table>
<tr class="row-1">
<td><img src="images/twitch-popout.png"></td>
<td><img src="images/youtube-popout.png"></td>
<tr class="row-2">
<!--<td class="tiktok-popout"><img src="images/tiktok-popout.png"></td>
<td class="twitter-popout"><img src="images/twitter-popout.png"></td> -->
<!--<tr class="link-images">
<td class="instagram-popout"><img src="images/instagram-popout.png"></td>
<td class="discord-popout"><img src="images/discord-popout.png"></td>
</tr> -->
</table>
</div>
</body>
CSS File:
*{
margin: 0;
padding: 0;
}
body {
background: url("images/background.jpg");
background-size: 100% 100%;
background-repeat: no-repeat;
}
.container{
display: block;
height: 91%;
border: 3px solid red;
position: relative;
}
.container td{
margin: 0;
}
.container img{
width: 40%;
}
.row-1{
position: absolute;
align-items: center;
}
I have tried many different things and nothing I have done works
Edit: I'm attaching a picture to show what it looks like as well
As per my comment, here is a way of creating a grid with 2 columns using CSS grid.
.container {
border: 3px solid red;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
}
.container img {
width: 100%;
height: 80px;
}
<div class="container">
<img src="images/twitch-popout.png">
<img src="images/twitch-popout.png">
<img src="images/twitch-popout.png">
<img src="images/twitch-popout.png">
<img src="images/twitch-popout.png">
<img src="images/twitch-popout.png">
</div>
I've got an html table inside a dojox/layout/ContentPane left region div. I can't get the table to center inside of the div. I've tried using: margin: 0 auto; in the css styling of the table, but the table is always left aligned. The table contains a dijit/layout/TabContainer with content panes that are populated with google charts (maybe these are impacting the layout?). Below is my code, any suggestions appreciated. In the screen shot the table border is in yellow and the div border is in orange on the left side of the image
<div data-dojo-type="dojox/layout/ContentPane" id="FormLeft" data-dojo-props="splitter: false, region:'left'">
<div id="FormLeft">
<table class="TblPieCharts">
<tr>
<td>
<div data-dojo-type="dijit/layout/TabContainer" class="TCPieChart" id="tcTickets">
<div data-dojo-type="dijit/layout/ContentPane" title="Categories" id="DACat"></div>
<div data-dojo-type="dijit/layout/ContentPane" title="Priorities" id="DAPriority"></div>
<div data-dojo-type="dijit/layout/ContentPane" title="Types" id="DAType"></div>
</div>
</td>
</tr>
<tr>
<td><div id="DAFYE" /></td>
</tr>
</table>
</div>
</div>
CSS:
/*style for content pane*/
#FormLeft {
width: 25%;
background-color:black;
border-width: 6px;
border-color:orange;
}
/*style for table holding pie charts*/
.TblPieCharts {
margin: 0 auto;
align-content:center;
background-color: yellow;
color: white;
}
/*style for tab container*/
.TCPieChart {
width: 350px;
height: 300px;
background-color: black;
margin: 0 auto;
border-width: 0px;
}
/*style for pie chart*/
#DACat {
width: 350px;
height: 250px;
background-color: black;
margin: 0 auto;
border-width: 0px;
}
Thanks
Pete
You can set text-align: center to the td containing tabcontainer.
I am making a game for a school assignment (mastermind), but i'm having trouble getting the divs to do what I want. I have a board div, with multiple other divs inside it ( 5 each row). I am now planning on making a second div next to it to have it display scores. However I can't seem to get the "scoresheet" div next to the "board" div. I have just picked up programming so my code may be really primitive or ineffecient. this is what I have thus far:
<div id="board">
<div id="turn0">
<div id="space0.0" class="spacex"></div>
<div id="space0.1" class="spacex"></div>
<div id="space0.2" class="spacex"></div>
<div id="space0.3" class="spacex"></div>
<div id="table0">
<table>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</div>
</div>
this is one row of the board, this code is copied with each row of the board.
the table is for displaying white or black pins based on the amount of colors you guessed correctly, the first four divs are previous displays for showing the colors you chose for the previous turn. the "board" div is used for displaying previous turns.
this is my CSS code on the "board" div:
#board{
width: 335px;
height: 600px;
margin: auto;
background-color: darkgrey;
left: 50%;
overflow: hidden;
}
this is the CSS for the first four squares inside the "board" div:
.spacex {
float: left;
width: 50px;
height: 50px;
margin: 6px;
vertical-align: center;
}
and lastly the CSS for the small table:
table, td {
border: 1px solid black;
height: 22px;
width: 50px;
margin; 4px;
}
I was thinking of having the "scoresheet" div stick to the right side of the page, up against the scrollbar.
I also don't know if using a table to display the amount of white and black pins is the best course of action, if you know a more efficiƫnt or smarter piece of coding then please let me know.
I am not at all familiar with more intricate pieces of coding, so if you could explain the steps, and function of each piece of code that would be much, much appreciated.
Thanks in advance for all the help.
I have now managed to get another div that will display highscores and other usefull information, which was the struglle I was having: to get a div that displays information to be placed to the right of the "board" div. It turned out be simpler than i thought, I just had to give the div a top and right value and posistion. While you all have been a great help, I still have two more issues remaining concerning the placement of my divs. Right now i have a button that is going to check if the guessed colors match the coputer generated color code, however I cant get the position of the button to change. I also have a problem with the the divs inside the "board" div not showing correctly. The whole concept behind the code is hard to explain, so I will copy the code I have thus far below:
HTML:
<!DOCTYPE html>
<html>
<head>
<title> Master Mind </title>
<meta charset="UTF-8">
<script src="script.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<p>
<h1> Master Mind </h1>
</p>
<div id="turn-interactive">
<div id="choosecolor0" class="colorfield"></div>
<div id="choosecolor1" class="colorfield"></div>
<div id="choosecolor2" class="colorfield"></div>
<div id="choosecolor3" class="colorfield"></div>
<form> <input type="button" value="Check!"name="button" class="button"></form>
</div>
<div id="board">
<div id="turn0">
<div id="space0-0" class="spacex"></div>
<div id="space0-1" class="spacex"></div>
<div id="space0-2" class="spacex"></div>
<div id="space0-3" class="spacex"></div>
<div id="table0">
<table>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</div>
</div>
<div id="board">
<div id="beurt0">
<div id="space0_0" class="spacex"></div>
<div id="space0_1" class="spacex"></div>
<div id="space0_2" class="spacex"></div>
<div id="space0_3" class="spacex"></div>
<div id="table0">
<table>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</table>
</div>
</div>
</div>
<aside><div id="infobar" class="infobar"></div></aside>
CSS:
body {
overflow: auto;
background-color: lightgrey;
height: 99%;
width: 99%;
}
div {
border: 2px solid black;
}
.infobar{
height: 600px;
width: 200px;
right: 50%;
overflow: hidden;
position: absolute;
top: 40%;
right: 0%;
background-color: white;
}
.button{
display: block;
height: 100px;
width: 300px;
background: #34696f;
border: 2px solid rgba(33, 68, 72, 0.59);
position: static;
top: 50%;
left: 75%;
}
}
.spacex {
float: left;
width: 50px;
height: 50px;
margin: 6px;
}
.colorfield {
float: left;
width: 120px;
height:120px;
background-color: white;
margin: 10px;
left: 50%;
}
#board{
width: 350px;
height: 600px;
margin: auto;
background-color: darkgrey;
left: 50%;
overflow: hidden;
}
#turn-interactive{
width: 1000px;
height: 150px;
background-color: red;
margin: auto;
margin-bottom: 10px;
top: 15%;
}
table, td {
border: 1px solid black;
height: 22px;
width: 50px;
margin; 4px;
}
the idea is to later (when I start coding the javascript) to have the values of the four colorfields displayed copied down below inside the "Board" div. The table inside the board div is for displaying the amount of white and black pins ( four colorfields, four squares inside the table). If you run the current code you can see that the four divs that are supposed to be displayed inside the "board" div before the table are not showing correctly, and are just creating a big black border inside the board." I have no clue of how I'm supposed to fix this. The four divs did show up correctly when i had just one row of "four colordivs-one table" ofcourse there is going to be a history of turns so I need muliple rows of four colordivs followed by a table displaying pins. Since it did work with only one row that had a table I'm guessing that the table is the troubleshooter. I translated the div ID's and class names from Dutch to English so it's clear what's what.
Again, thanks a bunch for the help.
PS. Since the website also is going to need a javascript code later on I thought that i should add the tag. Sorry about that, since my question indeed wasn't javascript related.
I think using a table to host your score is a god idea.
You could use position: absolute to position you table according to another element. This element is its Containing Block and you can indicate it is your board game by adding a position: relative to it.
If you do so, you can add left: 100% to your score sheet to make it stick on the right of your board.
#board {
position: relative;
width: 335px;
height: 600px;
margin: auto;
background-color: darkgrey;
}
#scoresheet {
position: absolute;
left: 100%;
width: 52px;
border-collapse: collapse;
}
#scoresheet td {
border: 1px solid black;
width: 22px;
height: 22px;
}
<div id="board">
<table id="scoresheet">
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
</div>
I made a CodePen of your example: http://codepen.io/angeliquejw/pen/MyJGaz?editors=1100
As #GCyrillus pointed out, you're going to want to swap the points/periods in your IDs with hyphens/dashes or underscores. I've used dashes here, but do what you want.
It's not clear from your question if you want the score table to appear inside the board (which is how it's coded) or at the upper right corner, regardless of the board. I added the following CSS to your example:
#table0 {
position:absolute;
top:0;
right:0;
}
If you want the table to be inside the board, you just need to add position:relative to the #board. I've added that already, but commented it out. I also commented out the left:50% which isn't doing anything at all in the current code and just mucks things up if/when you change the position of #board.
The reason that you can't put the scoresheet table next to the gameboard div, is because the table tag is nested inside of the gameboard div. So the gameboard div wraps around the table. Here is how to solve this issue: "However I can't seem to get the "scoresheet" div next to the "board" div."
Change this:
<div id="board">
...
<table>
...
</table>
</div>
To this: jsfiddle
<div id="board">
...
</div>
<table id="scoresheet">
...
</table>
To make them appear side-by-side, apply a left float to both of them:
#board,
#scoresheet {
float: left;
}
You can use that same float:left trick to horizontally align the spacex div tags into a row of squares. This would solve this issue: "I have a board div, with multiple other divs inside it ( 5 each row)." To create multiple rows, wrap them in a row div, which doesn't have a float applied to it.
<div id="row1" class="rows">
<div id="space0.0" class="spacex"></div>
<div id="space0.1" class="spacex"></div>
<div id="space0.2" class="spacex"></div>
<div id="space0.3" class="spacex"></div>
<div id="space0.4" class="spacex"></div>
</div>
<div id="row2" class="rows">
<div id="space1.0" class="spacex"></div>
<div id="space1.1" class="spacex"></div>
<div id="space1.2" class="spacex"></div>
<div id="space1.3" class="spacex"></div>
<div id="space1.4" class="spacex"></div>
</div>
.spacex {
float: left;
}
Try giving .spacex a border, background-color & margins/padding to style them up! Good luck! :)
I am wanting to have a page with a fixed-height header and footer, and with the contents taking 100% of the remaining height.
I currently have the behavior I desire working in Chrome, but in Internet Explorer, the row will grow beyond the desired height, forcing the footer off of the page (as evidenced by the scrollbar on the page). I can't find a fix for the Internet Explorer problem for the life of me.
Here is the desired behavior (in Chrome), note the row does not expand to fit contents, and instead has the ability to scroll:
Here is the undesired behavior I am experiencing with Internet Explorer:
Here is the approach I am taking:
<head>
<style>
body {
margin: 0px;
table-layout:fixed;
}
table {
border-collapse:collapse;
}
table, tr, td {
overflow:hidden;
padding: 0px;
}
</style>
</head>
<body>
<table style="width:100%; height:100%; top:0px; bottom:0px;">
<!--HEADER-->
<tr style="height:100px;">
<td colspan="2" style="background-color:#ff0000; text-align:center;">
<h1>Piano Festival</h1>
</td>
</tr>
<!--CONTENTS-->
<tr>
<!--LEFT CONTENT PANE-->
<td style="background-color:#ff00ff;">
<div style="height:100%; overflow-y:scroll;">
<form>
<!--Form contents here-->
</form>
</div>
</td>
<!--RIGHT CONTENT PANE-->
<td style="background-color:#00ffff; width:100%;">
</td>
</tr>
<!--FOOTER-->
<tr style="height:100px;">
<td colspan="2" style="background-color:#00ff00";>
</td>
</tr>
</table>
</body>
I'd prefer to avoid using any Javascript or CSS extensions. How can I work around this problem so that I get the same behavior in IE that I have in Chrome right now (scrollable contents instead of a growing row height)?
I also highly recommend not using tables for this. Here is a refactored version using divs to get you started.
HTML:
<div class="header">
<h1>Piano Festival</h1>
</div>
<div class="registration">
...lots of stuff....
</div>
<div class="main">
Main section
</div>
<div class="footer">
footer
</div>
And here's the CSS:
body, html {
height: 100%;
}
* {
margin: 0;
padding: 0;
}
.header {
margin: 0;
background: darkgreen;
height: 10%;
}
.registration {
background: deeppink;
width: 20%;
overflow: auto;
height: 80%;
float: left;
}
.main {
display: inline-block;
}
.footer {
background: blue;
height: 10%;
position: fixed;
width: 100%;
bottom: 0;
}
Here's a working demo.
I'm struggling to get my 3 tables to be centered in the page.
Here's a picture of what it looks like currently:
Basically (from look at the image), I want the second/middle table ("Work" table) to be the only table in center, and the other 2 tables ("About" and "Collaborate" tables; left and right from the middle, respectively) to have spread out a bit (using margin, I would assume).
Here's my HTML:
.fixedWidth2 {
margin: 0 auto;
width: 1000px;
height: 350px;
background-color: green;
border: 2px solid yellow;
}
.tableProp1 {
width: 200px;
float: left;
margin-left: ;
}
.tableProp1 tr td {
height: 200px;
color: red;
}
.tableProp2 {
margin-left: 40px;
width: 200px;
float: left;
}
.tableProp2 tr td {
height: 200px;
color: pink;
}
.tableProp3 {
margin-left: 40px;
width: 200px;
float: left;
}
.tableProp3 tr td {
height: 200px;
color: blue;
}
<div id="mainContent">
<div class="fixedWidth2">
<table class="tableProp1" border="1">
<tr>
<th>About</th>
</tr>
<tr>
<td>Learn more about me and my accomplishments.</td>
</table>
<table class="tableProp2" border="1">
<tr>
<th>Work</th>
</tr>
<tr>
<td>I tend to get involved with a lot of different projects. Ranging from a simple photoshop gig to having a small role in a television/pilot</td>
</tr>
</table>
<table class="tableProp3" border="1">
<tr>
<th>Collaborate</th>
</tr>
<tr>
<td>Have a brand new or idea of a project? Whatever help you may need, I may be of some assistance to</td>
</tr>
</table>
</div>
<!-- Fixed Width 2 DIV for Main Content DIV -->
</div>
<!-- mainContent DIV -->
Since you are using fixed widths for your tables and you're floating them, I would wrap them in a container, set the width on that to match all three tables+margin and set margin: auto on the container
.table-wrapper{
width: 680px;
margin: auto;
}
JSFIDDLE
Alternatively you can just use display: inline-block instead of float:left and add text-align: center to .fixedWidth2
ALT FIDDLE
I would not use <table> at all... table are good for tabular content, not for templating....
I would use DIV or even HTML5's <article> and <section>.
Think also about SEO, <h2> is a better mirror to your website semantic toward search engines than table's TH ...
To center three elements you can simply set them display: inline-block; with some vertical-align, than just setting the <div class="centered"> to text-align: center; will center-align your inner elements. You can also use float:left; but I've not covered that example.
http://jsbin.com/roruqo/1/
<div id="container">
<div id="slider"></div>
<div id="mainContent">
<div class="centered">
<div class="fixedWidth2">
<h2>About</h2>
<p>Learn more about me and my accomplishm...</p>
</div>
<div class="fixedWidth2">
<h2>Work</h2>
<p>I tend to get involved with a lot of d...</p>
</div>
<div class="fixedWidth2">
<h2>Collaborate</h2>
<p>Have a brand new or idea of a project?...</p>
</div>
</div>
</div><!-- mainContent DIV -->
</div>
h2, p{
padding:15px;
margin:0;
}
#container{
width:960px;
margin:0 auto;
background:#eee;
}
#slider{
background:blue;
height:400px;
}
.centered{
text-align:center;
}
.centered > div{
text-align:left;
}
.fixedWidth2{
min-height:170px;
background:#ddd;
display:inline-block;
vertical-align:top;
width: 250px;
margin: 15px;
}
.fixedWidth2 h2{
text-align:center;
background:#aaa;
}
<div id="mainContent">
<div class="fixedWidth2">
<div class="row">
<table class="tableProp1" border="1">
<tr>
<th>About</th>
</tr>
<tr>
<td>Learn more about me and my accomplishments.</td>
</table>
<table class="tableProp2" border="1">
<tr>
<th>Work</th>
</tr>
<tr>
<td>I tend to get involved with a lot of different projects. Ranging from a simple photoshop gig to having a small role in a television/pilot</td>
</tr>
</table>
<table class="tableProp3" border="1">
<tr>
<th>Collaborate</th>
</tr>
<tr>
<td>Have a brand new or idea of a project? Whatever help you may need, I may be of some assistance to</td>
</tr>
</table>
</div>
</div>
</div>
add this style in style sheet
.row {
margin: 0 auto;
width: 680px;
}
add "row " division and apply this style then check it's working properly.