Grid System in CSS - html

I would like to display 3 white blocks in a blue container. Each with a 10px margin between.
Currently I have this:
<div class="wbg-create">
<div class="full-create">
<div class="white-create">
<br/>
<br/>
<br/>
<br/>
<br/>
<t class="f30 helv grey">Create Group</t>
<br/>
<br/>
<br/>
<t class="f30 helv-b grey">Group Name</t>
<br/>
<br/>
<input class="gen-input helv-b">
<br/>
<br/>
<br/>
<t class="f30 helv-b grey">Array Type</t>
<br/>
<br/>
<select class="gen-input helv txtind-10">
<option>Option 1</option>
<option>Option 2</option>
</select>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<button class="b_next"><b>Next</b></button>
</div>
<div class="white-create" style="margin: 0 auto;"></div>
</div>
</div>
.wbg-create{
position: absolute;
width: 84%;
background-color: #f3fbff;
border-radius: 50px;
height: 98vh;
margin-top: 0px;
text-align: center;
}
.f30{
font-size: 30px;
}
.helv{
font-family: Helvetica Neue;
}
.helv-b{
font-family: Helvetica Neue;
font-weight: bold;
}
.grey{
color: #545454;
}
.gen-input{
background-color: #e3e8ed;
height: 50px;
width: 300px;
border-radius: 30px;
border-color: transparent;
text-align: center;
font-size: 20px;
}
.txtind-10{
text-indent: 10px;
}
.full-create{
margin: 10px;
}
.white-create{
left: 50%;
width: 33%;
background-color: white;
border-radius: 50px;
height: 96vh;
}
.b_next{
border-radius: 50px;
height: 45px;
text-align: center;
width: 100px;
font-size: 20px;
background-color: #cad2e7;
color: #28284c;
border-color: transparent;
bottom: 30px;
}
.b_next:hover{
border-radius: 50px;
height: 45px;
text-align: center;
width: 100px;
font-size: 20px;
background-color: #dde7ff;
color: #4e4e95;
border-color: transparent;
}
.b_next:active{
border-radius: 50px;
height: 45px;
text-align: center;
width: 100px;
font-size: 20px;
background-color: #ffffff;
color: #30a3f5;
border-color: transparent;
}
I know this is really messy, and I should be using margin and padding instead of <br/> but I find it a very long process. My web-app is only run in full-screen and cannot be resized, so it shouldn't be too much of a problem.
How do I get these containers to appear side-by-side?
Currently, there are side-by-side, but they appear below the previous one.
Like this:
[]-should be here-
[]
[]
How can I fix this?

A dirty hack:
.white-create{display:inline-block;}
Better:
Have a look at Common CSS Flexbox Layout Patterns with Example Code
More infos: MDN flexbox

Using grid.
.wbg-create {
display: grid;
grid-template-columns: repeat(3, 1fr)
grid-gap: 10px;
}
Here's a pen with the working answer.
https://codepen.io/jorgeberen/pen/wvKVBNN
Using flex should do the trick too.
.wbg-create {
display: flex;
}
Because display:flex displays the items within the container by default in a horizontal row, your three white blocks should be displayed side by side. For this case scenario it is simpler than using grid.

Related

Elements shifting to left even with float-right

Please look into this jsfiddle code.
Elements in right columns are incrementally shifting to left, even though I've used float-right.
I wanted the right column to be aligned to right border, just as the first value under Jenkins.
Please suggest what am I missing.
Thank You
In this case you may probably want to use text-align: right in the parent div instead of a float on the elements themselves. Float is not typically used for aligning content, but for aligning the containers of that content. It's often used for layouts. Text-align makes more sense here, because you want to align text.
Please remove the float-right from a tags of "metrics-content-t2" div and use text-align right.
.metric-div-row {
width: 100%;
display: flex;
}
.metric-div-row>div {
flex: 1;
margin-top: 5px;
margin-bottom: 2px;
margin-left: 10px;
margin-right: 10px;
/* Adding Border */
border-radius: 12px;
border: 2px solid cadetblue;
padding: 20px;
width: 200px;
height: 150px;
padding-top: 10px;
padding-bottom: 30px;
background-color: white;
}
.all-project-heading {
width: 100%;
height: 25px;
font-size: 18px;
font-weight: 600;
color: darkslategray;
}
.metrics-content {
width: 100%;
height: 120px;
}
.metrics-content-t1 {
float: left;
}
.metrics-content-t2 {
float: right;
text-align:right;
}
.metrics-heading {
margin-bottom: 5px;
font-size: 13px;
font-weight: 500;
}
.metrics-value-small {
color: #119bc9;
font-size: 15px;
font-weight: 500;
text-decoration: none;
border: 0px;
margin-bottom: 5px;
}
.floatRight {
float: right;
}
<div class="metric-div-row">
<div class="metric-divs">
<div class="all-project-heading">
CI Statistics
</div>
<br/>
<div class="metrics-content">
<div class="metrics-content-t1">
<span class="metrics-heading">Deployer</span>
<br/>
<a id="ciDeployerCount" class="metrics-value-small">0</a>
<br/>
<br/>
<span class="metrics-heading">GoCD</span>
<br/>
<a id="ciGocdCount" class="metrics-value-small">0</a>
<br/>
<br/>
<span class="metrics-heading">Other</span>
<br/>
<a id="ciOtherCount" class="metrics-value-small">0</a>
</div>
<div class="metrics-content-t2">
<span class="metrics-heading">Jenkins</span>
<br/>
<a id="ciJenkinsCount" class="metrics-value-small">0</a>
<br/>
<br/>
<span class="metrics-heading">TFS</span>
<br/>
<a id="ciTfsCount" class="metrics-value-small">0</a>
<br/>
<br/>
<span class="metrics-heading">None</span>
<br/>
<a id="ciNoneCount" class="metrics-value-small">0</a>
</div>
</div>
</div>

Why are my elements losing position?

So here is my box:
BOX
Ok, now I want to add box near the input of the BET box.
<div id="x2"></div> <!-- HTML --->
/* CSS */
#x2{
width: 40px;
height: 40px;
background: cornflowerblue;
}
The box after I add it:
BOX-AFTER
As you can see, it messed up the thin gray line and everything underneath it. I'm really not sure why.
HTML:
<div class="gamebox">
<div id="bet-and-chance-texts">
<p id="bettext">BET</p>
<p id="profittext"><i class="fa fa-btc" aria-hidden="true"></i> PROFIT</p>
</div>
<div id="bet-and-chance-input-boxes">
<input class="default" id="userbet" onkeyup="checkBet()" value="0.00000000" placeholder="BTC" name="bet" autocomplete="off">
<div id="x2">x2</div>
<input readonly class="default" id="profitinput" onkeyup="" value="100" placeholder="BTC" name="bet" autocomplete="off">
</div>
<br>
<div class="line-separator"></div>
<div id="button-texts">
<p id="roll">ROLL UNDER</p>
<p id="payout">PAYOUT</p>
<p id="chance">CHANCE</p>
</div>
<div id="buttons">
<input class="hidden-boxed-input-roll" value = "50.00"/>
<input autocomplete="off" id="newpayout" onkeyup="calculateChance()" class="hidden-boxed-input" value = "2.000"/>
<input autocomplete="off" id="newchance" onkeyup="checkChance()" class="hidden-boxed-input" value = "50"/>
</div>
<br>
<div id="rolldice-section">
<button type="button" id="dicebutton" onclick="prepareRoll(authToken);" style="vertical-align:middle"><i class="fa fa-gamepad"></i> Roll dice</button>
</div>
</div>
CSS:
.gamebox {
height: auto;
padding: 20px;
width: 60%;
font-family: Helvetica Neue;
color: black;
margin-top: 20px;
margin-left: 20px;
background-color: white;
}
.line-separator{
height:.5px;
background: lightgray;
border-bottom:.5px solid lightgray;
}
#x2{
width: 40px;
height: 40px;
background: cornflowerblue;
float: left;
}
input[class="default"]{
padding: 12px 20px;
margin : 0 auto;
box-sizing: border-box;
text-align: center;
background-color: #E4ECF1;
display: inline-block;
}
p[id="roll"]{
display: inline-block;
float: left;
font-size: 13px;
}
p[id="payout"]{
display: inline-block;
margin-right: 25px;
font-size: 13px;
}
p[id="chance"]{
display: inline-block;
float: right;
font-size: 13px;
}
div[id=button-texts]{
text-align: center;
}
Why does everything below the thin gray line get messed up? How can I solve this?
Change this :
<div id="x2">x2</div>
to :
<span id="x2">x2</span>
since div have block display and you need to use span which is inline
then change your style, remove float and add some padding to #x2 :
#x2 {
padding: 13px;
width: 40px;
height: 40px;
background: cornflowerblue;
}

Line Height for placeholder in Input won't move to top

I have been trying to play with line-height, formatting input for all browsers, padding, vertical-align and so forth but my placeholder still is in the middle of the box. Any suggestions?
I tried testing my code within jsfiddle to see if maybe it's just my css file, however; the results are the same.
http://jsfiddle.net/f0o4bcnv/
#postdoc {
background-color: gray;
width: 780px;
height: 500px;
margin-right: auto;
margin-left: auto;
border: 1px solid black;
margin-top: 30px;
margin-left: 30px;
padding-top: 30px;
float: right;
}
#postdoc label {
float: left;
width: 200px;
text-align: right;
margin-right: 10px;
padding-left: 10px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
font-size: 25px;
margin-bottom: 30px;
margin-left: 20px;
}
#postdoc input[type="text"] {
margin-bottom: 30px;
height: 300px;
width: 500px;
font-size: 20px;
margin-left: 10px;
box-shadow: 0 0 5px black;
vertical-align: top;
/*padding-top: 0;*/
/*line-height: normal;*/
/*line-height: none;*/
/*vertical-align: top;*/
/*-webkit-input-placeholder: line-height: 1.5em;
-moz-placeholder: line-height: 1.5em;
-moz-placeholder: line-height: 1.5em;
-ms-input-placeholder: line-height: 1.5em;*/
}
#postdoc input[type="file"] {
margin-bottom: 30px;
height: 50px;
width: 500px;
font-size: 20px;
margin-left: 10px;
box-shadow: 0 0 5px black
}
#postdoc input[type="submit"] {
margin-bottom: 30px;
height: 45px;
width: 250px;
font-size: 30px;
margin-right: 100px;
float: right;
background-color: #4EA24E;
color: blue;
border-radius: 5px;
text-shadow: 0 0 10px yellow;
box-shadow: 0 0 10px black;
font-family: Rockwell, 'Courier Bold', serif;
}
#postdoc input[type="submit"]:hover {
color: gold;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="prostylesheet.css" type="text/css">
<meta http-equiv="X-UA-Compatible" content="IE=80" />
</head>
<body>
<h1 class="name"><font color = "#3399FF"> Prog-Assist | </font><font size = "12" font color = "#4EA24E"> Programs Deployed</font></h1>
<div id="header">
<div id="gradient">
<div class="nav">
<!-- container-fluid gives full width container of whole viewport -->
<div class="container-fluid">
<ul id="nav1" class="text-left">
<li><strong>Home
</li>
<li>Technologies
</li>
<li>Programs
</li>
<li>Blog</strong>
</li>
</ul>
<ul id="nav2" class="text-right">
<li><strong>Sign In
</li>
<li>Contact</strong>
</li>
</ul>
</div>
<!-- end container-fluid-->
</div>
<!--end nav-->
</div>
</div>
<!-- end header -->
<form id="postdoc" action="upload.php" method="POST" enctype="multipart/form-data">
<label>Comment:</label>
<input type="text" name="comment" placeholder="Comments">
<br>
<label>Text Document:</label>
<input type="file" name="documentfile" />
<br>
<input type="submit" name="submit" value="Post comment" class="button">
</form>
</body>
</html>
For this cases (multiline) you should use textarea:
<textarea style="height: 500px; width: 100%;">
Comments
</textarea>
Note: Input element only support single line.
I don't have an actual explanation for this. My guess would be the height distibutes evenly from top to bottom so the text sits in the middle. A solution would be to use padding instead:
#postdoc input[type="text"] {
margin-bottom: 30px;
/*height: 300px*/ //remove
width: 500px;
font-size: 20px;
margin-left: 10px;
box-shadow: 0 0 5px black;
padding: 0 0 50px; //add
}
FIDDLE
But if this is not for cosmetics and you're looking to let a user type a block of text, you should use <textarea></textarea> instead of <input/>.
You should use textarea instead of input.
Look this fiddle:
<textarea name="comment" placeholder="Comments"></textarea>
http://jsfiddle.net/f0o4bcnv/4/
To style the placeholder you can also use this css code:
::-webkit-input-placeholder { /* WebKit browsers */
color: red;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
color: red;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
color: red;
}
:-ms-input-placeholder { /* Internet Explorer 10+ */
color: red;
}
Note that only works on newer browsers.

input:text different positioning in different browsers

I have two textfields inside a div. In Chrome, Opera and Safari, the second textfield is positioned a little bit more left than upper one.
Hovewer in Safari and IE it is positioned just right.
Here is the codepen for you to try : http://codepen.io/anon/pen/PwoKZr
Here is a simple image that shows the problem:
Here is the relevant part:
<body style="
font-size: 14px;">
<div id="container" class="container_16">
<div id="mainSection" class="grid_16">
<div id="newUserBox" style="
text-align: center;
">
<input id="userEmail" type="text" style="
/* text-align: center; */
width: 300px;
padding: 8px 10px;
font-size: 18px;
" placeholder="E-Mail"><br>
<input id="userPass" type="text" style="
/* text-align: center; */
width: 300px;
/* margin-right: 5px; */
margin-top: 10px;
padding: 8px 10px;
font-size: 18px;
" placeholder="Password">
<br>
<button style="
width: 324px;
margin-top: 10px;
border-radius: 0px; clear: both;
padding: 8px 10px; border: none; background-color: #3FC66F;
font-size: 20px; color: #fff;
">Log In</button>
</div>
</div>
</div>
</body>
Try not to use br to position the textboxes
Remove the br and apply the following styles
#newUserBox{text-align: center;width: 300px; margin:0 auto;}
Side note: try not to use inline-styles

Drop Downs Disappear & Can't Center Button

I'm admitting right at the start: this is my first attempt at HTML/CSS coding. So please excuse my code's messiness.
I have two problems: 1. When I shrink my browser window small enough to see a scroll bar, my three drop down menus disappear. 2. I am trying to center my button (Find Resources), but can't figure it out. I've tried auto-ing my left and right margins, I tried text aligning, but it messed up the placement of my three boxes (which have a width of 200px).
Thanks for any help someone can offer!
HTML:
<div id="resource-wrapper">
<div id="content">
<p class="resource-p">Welcome to Our Resource Center.</p>
<p class="resource-p">How may we help you?</p>
</div>
<div id=buttons-div>
<div id=select>
<select class="dropdown" name="field_related_brands_nid">
<option value="All" selected="selected">Any</option>
<option value="2511">Sample</option>
</select>
<select class="dropdown-2" name="field_related_technology_nid">
<option value="All" selected="selected">Any</option>
<option value="444">Sample</option>
</select>
<select class="dropdown-3" name="field_resource_type_value_many_to_one">
<option value="All" selected="selected">Any</option>
<option value="multimedia">Sample</option>
</select>
</div>
<div id=buttons>
<img src="Images/Buttons1.jpg" class="resource-image">
<img src="Images/Buttons2.jpg" class="resource-image">
<img src="Images/buttons3.jpg" class="resource-image">
</div>
<button type="submit" class="resource-p1">Find Resources</button>
</div>
</div>
CSS:
#resource-wrapper {
width: 850px;
margin: 0 auto;}
#content {
background-color: #669bcf;
padding: 1px;
width: 100%;}
.resource-p {
text-align: center;
font-size: 30px;
font-family: sans-serif;
color: white;
line-height: 15px}
#buttons-div {
position: relative;
width: 850px;}
#select {
position: fixed;
margin-top: 214px;
width: 850px;}
.dropdown {
width: 160px;
margin-left: 78px;}
.dropdown-2 {
width: 125px;
margin-left: 115px;}
.dropdown-3 {
width: 95px;
margin-left: 148px;}
.resource-image {
margin: 50px 0 0 58px;}
.resource-p1 {
padding: 16px 18px 13px 18px;
margin: 20px;
text-align: center;
font-size: 21px;
font-family: sans-serif;
color: white;
font-weight: bold;
background-color: #669bcf;
border-style: solid;
border-width: 1px 1px 3px 1px;
border-color: #d7e4f4;
border-radius: 5px;}
Your Dropdowns shouldn't stack as nothing is responsive in your site. If they have a set width like width: 800px; They should be fine. However make sure to have all your id's surrounded with a quote:
<div id=buttons-div>
should be
<div id="buttons-div">
To Center your Resource Button:
.resource-p1 {
margin: 12px auto;
text-align: center;
font-size: 21px;
font-family: sans-serif;
color: white;
font-weight: bold;
background-color: #669bcf;
border-style: solid;
border-width: 1px 1px 3px 1px;
border-color: #d7e4f4;
border-radius: 5px;
display: block;
}
DEMO
1) Change #select's position from fixed to absolute
2) Wrap your button in a container and give that container text-align:center
HTML
<div id="find-resources-container">
<button type="submit" class="resource-p1">Find Resources</button>
</div>
CSS
#find-resources-container {
text-align:center
}