I'm creating a input to contain hours and minutes.I use this html elements:
Two pairs of up and down Buttons;
Input text.
I'm having trouble aligning the html elements.
This is the image with the best alignment I could apply:
This is my code:
.col-centered{
float: none;
margin: 0 auto;
}
.row-1{
padding-top: 3px;
padding-right: 0px;
padding-bottom: 1px;
padding-left: 0px;
}
.triangle-up {
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-bottom: 8px solid #555;
}
.triangle-down {
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 8px solid #555;
}
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-xs-1">
<div class="row-1">
<div class = "triangle-up" id ="up1"></div>
</div>
<div class="row-1">
<div class = "triangle-down" id ="down1"></div>
</div>
</div>
<div class="col-xs-2">
<div class = "col-centered">
<input type="text" id="hora" size="5" maxlength="5">
</div>
</div>
<div class="col-xs-1">
<div class="row-1">
<div class = "triangle-up" id ="up"></div>
</div>
<div class="row-1">
<div class = "triangle-down" id ="down"></div>
</div>
</div>
</div>
</div>
I tried, but without success, lining up the elements with pulling to the right. Forcing the left pair of Buttons, to be near the html text entry.
I've changed this piece of code:
<div class="pull-right">
<div class="row-1">
<div class = "triangle-up" id ="up1"></div>
</div>
<div class="row-1">
<div class = "triangle-down" id ="down1"></div>
</div>
</div>
How can I align the html elements so that the two pairs of buttons are close to the input element of text?
This would be a great use case for flexbox! Before, you had things inside the bootstrap grid, which was probably adding the extra spacing you didn't want. For a custom component look, you'd need to just space things out the way you want them to look. Now the triangles are spaced out evenly vertically - even if the height of the <input> is increased!
.spinner-input-wrapper {
display: flex;
}
.spinner {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.spinner-input {
margin: 0 3px;
}
.triangle-up,
.triangle-down {
width: 0;
height: 0;
border: 4px solid transparent;
}
.triangle-up {
border-bottom-width: 8px;
border-bottom-color: #555;
}
.triangle-down {
border-top-width: 8px;
border-top-color: #555;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="container">
<div class="spinner-input-wrapper">
<div class="spinner">
<div class="triangle-up" id="up1"></div>
<div class="triangle-down" id="down1"></div>
</div>
<input type="text" class="spinner-input" size="5" maxlength="5">
<div class="spinner">
<div class="triangle-up" id="up2"></div>
<div class="triangle-down" id="down2"></div>
</div>
</div>
If you don't want to learn something else like flexbox all you really need is to clean up your code a bit. In this case the bootstrap layout is making it more difficult. Try simplifying to something like this. Here's my codepen sample
HTML
<div class="container">
<div class="triangles">
<div class="triangle-up" id="up1"></div>
<div class="triangle-down" id="down1"></div>
</div>
<div class="input-text">
<input type="text" id="hora" size="5" maxlength="5">
</div>
<div class="triangles">
<div class="triangle-up" id="up1"></div>
<div class="triangle-down" id="down1"></div>
</div>
</div>
CSS
.triangle-up {
margin-bottom: 6px;
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-bottom: 8px solid #555;
}
.triangle-down {
width: 0;
height: 0;
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 8px solid #555;
}
.triangles {
float: left;
display: inline-block;
padding: 2px 5px;
}
.input-text {
float: left;
display: inline-block;
}
Related
I'm having an issue related to using divs with the display set to table-cell. The purpose of using table-cell was so that the height of these two divs would match up. However, each of these divs also have another div set inside it to create the yellow dotted outline you see in the picture:
When one of the table cells grow, the yellow outline of the other doesn't grow to match its adjacent one. Hoping someone can help me with a fix, any help appreciated. Here is my code below:
.generalinfocontainer {
width: 50%;
height: auto;
background-image: url("https://imgur.com/qbIkHqm.png");
display: table-cell;
border-radius: 25px;
text-shadow: 1px 1px #000000;
}
.statscontainer {
width: 30%;
height: auto;
background-image: url("https://imgur.com/qbIkHqm.png");
display: table-cell;
border-radius: 25px;
text-shadow: 1px 1px #000000;
}
.t {
display: table;
width: 100%;
border-spacing: 20px;
}
.generalinfowrapper {
border-width: 2px;
border-color: yellow;
border-style: dashed;
margin: 3px;
border-radius: 25px;
height: 100%;
padding: 8px;
}
.statswrapper {
border-width: 2px;
border-color: yellow;
border-style: dashed;
margin: 3px;
border-radius: 25px;
height: 100%;
padding: 8px;
}
.statbar {
border-radius: 15px;
background-image: url("https://imgur.com/gdh95cn.png");
padding: 1px;
width: 100%;
height: auto;
border-style: solid;
border-color: black;
border-width: 1px;
}
.fillbar {
border-radius: 15px;
background-color: #a3c1ad;
height: 100%;
padding-left: 4px;
border-color: black;
border-width: 1px;
border-style: solid;
margin: 0px;
}
.boxtitle {
text-align: center;
}
<div class="t">
<div class="generalinfocontainer">
<div class="generalinfowrapper">
[b][size=24][color=yellow]KOMON HYUUGA[/color][/size][/b]
</div>
</div>
<div class="statscontainer">
<div class="statswrapper">
<div class="boxtitle">
[b][size=24][color=yellow]STATISTICS[/color][/size][/b]
</div>
[b]VIGOR[/b]<br />
<div class="statbar">
<div class="fillbar" style="width:80%;"> 80/100</div>
</div>
[b]CHAKRA[/b]<br />
<div class="statbar">
<div class="fillbar" style="width:80%;"> 80/100</div>
</div>
[b]SPEED[/b]<br />
<div class="statbar">
<div class="fillbar" style="width:80%;"> 80/100</div>
</div>
[b]STRENGTH[/b]<br />
<div class="statbar">
<div class="fillbar" style="width:80%;"> 80/100</div>
</div>
</div>
</div>
The purpose of using table-cell was so that the height of these two divs would match up.
Well, what you are trying to achieve can be done with less code using Flexbox, or CSS Grid. Take a look:
.t {
display: grid;
grid-template-columns: 2fr 1fr;
gap: 20px;
}
.generalinfocontainer,
.statscontainer {
background-image: url("https://imgur.com/qbIkHqm.png");
border-radius: 25px;
text-shadow: 1px 1px #000000;
border-width: 2px;
border-color: yellow;
border-style: dashed;
padding: 8px;
}
.statbar {
border-radius: 15px;
background-image: url("https://imgur.com/gdh95cn.png");
padding: 1px;
border: 1px solid solid black;
}
.fillbar {
border-radius: 15px;
background-color: #a3c1ad;
padding-left: 4px;
border: 1px solid black;
}
.boxtitle {
text-align: center;
}
<div class="t">
<div class="generalinfocontainer">
<div class="generalinfowrapper">
[b][size=24][color=yellow]KOMON HYUUGA[/color][/size][/b]
</div>
</div>
<div class="statscontainer">
<div class="statswrapper">
<div class="boxtitle">
[b][size=24][color=yellow]STATISTICS[/color][/size][/b]
</div>
[b]VIGOR[/b]<br />
<div class="statbar">
<div class="fillbar" style="width:80%;"> 80/100</div>
</div>
[b]CHAKRA[/b]<br />
<div class="statbar">
<div class="fillbar" style="width:80%;"> 80/100</div>
</div>
[b]SPEED[/b]<br />
<div class="statbar">
<div class="fillbar" style="width:80%;"> 80/100</div>
</div>
[b]STRENGTH[/b]<br />
<div class="statbar">
<div class="fillbar" style="width:80%;"> 80/100</div>
</div>
</div>
</div>
</div>
I have this issue where I need to apply some style to a div only if it's next to a visible item (even if there's non visible items in between, but not if all the items following the current one are all invisible), as shown here:
https://stackblitz.com/edit/js-3nulnw?file=style.css
.container {
display: flex;
flex-grow: 1;
padding: 5px;
}
.content {
border: 1px solid #000000;
border-radius: 4px;
width: 50%;
padding: 10px;
}
.addon {
width: 10%;
background-color: #ff0000;
border: 1px solid #000000;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
border-left: none;
}
.addon.hidden {
display: none;
}
.content:not(:last-child),
.addon:not(:last-child) {
border-right: none;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
<div class="container">
<div class="content">This is shown correctly (no addons)</div>
</div>
<div class="container">
<div class="content">This is shown correctly (one addon)</div>
<div class="addon"></div>
</div>
<div class="container">
<div class="content">
This is shown correctly (multiple addons, one is hidden)
</div>
<div class="addon hidden"></div>
<div class="addon"></div>
</div>
<div class="container">
<div class="content">This is shown correctly (multiple addons)</div>
<div class="addon"></div>
<div class="addon"></div>
</div>
<div class="container">
<div class="content">This should have all rounded borders</div>
<div class="addon hidden"></div>
</div>
<div class="container">
<div class="content">This should have all rounded borders</div>
<div class="addon"></div>
<div class="addon hidden"></div>
</div>
I have tried looking on the internet but to no avail, but I'm probably looking for the wrong answer (most of what I found were other SO questions saying there's no CSS selector for non visible item), so alternative ways to do this are welcome (possibly without JS)
Yes it is possible. I try to understand your question and get this result. Please expalin more your question
https://developer.mozilla.org/en-US/docs/Web/CSS/:is
We can get it through (:is) pseudo-class function. we can check if div has class like visible in below example case then we can apply style to its next div throught (+) adjacent sibling selector or (~) general sibling selector. I hope example will clear what I want to say
<div class="container">
<div class="content">This is shown correctly (no addons)</div>
</div>
<div class="container">
<div class="content">This is shown correctly (one addon)</div>
<div class="addon"></div>
</div>
<div class="container">
<div class="content">
This is shown correctly (multiple addons, one is hidden)
</div>
<div class="addon hidden"></div>
<div class="addon"></div>
</div>
<!-- [ADD 'visible' CLASS BEFORE OF TARGET CONTAINER] -->
<div class="container visible">
<div class="content">This is shown correctly (multiple addons)</div>
<div class="addon"></div>
<div class="addon"></div>
</div>
<div class="container">
<div class="content">This should have all rounded borders</div>
<div class="addon hidden"></div>
</div>
<div class="container">
<div class="content">This should have all rounded borders</div>
<div class="addon"></div>
<div class="addon hidden"></div>
</div>
and its css will be
.container {
display: flex;
flex-grow: 1;
padding: 5px;
}
.content {
border: 1px solid #000000;
border-radius: 4px;
width: 50%;
padding: 10px;
}
.addon {
width: 10%;
background-color: #ff0000;
border: 1px solid #000000;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
border-left: none;
}
.addon.hidden {
display: none;
}
.content:not(:last-child),
.addon:not(:last-child) {
border-right: none;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.container:is(.visible) + .container{
background-color: rebeccapurple;
color: white;
/* Your style here */
}
.container:is(.visible) + .container .addon{
background-color: brown;
color: white;
/* Your style here */
}
I found a horrible but apparently effective way of achieving what I wanted
https://stackblitz.com/edit/js-4hkorq?file=style.css
.container {
display: flex;
flex-grow: 1;
padding: 5px;
}
.content {
border: 1px solid #000000;
border-radius: 4px;
width: 50%;
padding: 10px;
}
.addon {
width: 10%;
background-color: #ff0000;
border: 1px solid #000000;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
border-left: none;
}
.addon.hidden {
/* display: none; */
visibility: hidden;
width: 0px;
}
.content:not(:last-child),
.addon:not(:last-child) {
border-right: none;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.container > div:last-of-type.hidden::before {
content: '';
border: 1px solid #000000;
border-radius: 4px;
border-left: none;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
height: 100%;
display: flex;
width: 4px;
visibility: visible;
position: relative;
top: -1px;
}
.container > .addon + div:last-of-type.hidden::before {
background-color: #ff0000;
}
<div class="container">
<div class="content">This is shown correctly (no addons)</div>
</div>
<div class="container">
<div class="content">This is shown correctly (one addon)</div>
<div class="addon"></div>
</div>
<div class="container">
<div class="content">
This is shown correctly (multiple addons, one is hidden)
</div>
<div class="addon hidden"></div>
<div class="addon"></div>
</div>
<div class="container">
<div class="content">This is shown correctly (multiple addons)</div>
<div class="addon"></div>
<div class="addon"></div>
</div>
<div class="container">
<div class="content">This should have all rounded borders</div>
<div class="addon hidden"></div>
</div>
<div class="container">
<div class="content">This should have all rounded borders</div>
<div class="addon"></div>
<div class="addon hidden"></div>
</div>
The trick is to use visibility: hidden and width: 0 instead of display: none, then add a ::before pseudo element that adds the border. It has the drawback of adding 4 pixels to the element (in order to have a 4 pixels border radius it needs to be at least 4 pixels wide) but it is acceptable in my case and (albeit with some tweaks) it also worked in my application.
For some reason I had to add top: -1px because it wouldn't align otherwise, but in my application I didn't need to do
These are the major changes to CSS
.container {display: table; table-layout: fixed; width: 100%...}
.addon {display: table-cell; position: relative; right: 5px;
z-index: 1; padding-right: 5px;...}
.addon+.addon {right: 10px; padding-right: 10px;...}
.content {display: table-cell;}
Since this is a pure CSS solution, the tags were changed so that :*-type-of works effectively. If you want a uniform height, add a div inside .content and give it an absolute height (ie px)
section:first-of-type > div {
border-top: 1px solid #000000;
}
section:last-of-type > div {
border-bottom: 1px solid #000000;
}
.container {
display: table;
table-layout: fixed;
width: 100%;
}
.content {
display: table-cell;
padding: 15px;
width: 50%;
border-left: 1px solid #000000;
border-right: 1px solid #000000;
border-top: 0.5px solid #000000;
border-bottom: 0.5px solid #000000;
border-radius: 4px;
}
.addon {
display: table-cell;
width: 10%;
position: relative;
right: 5px;
padding-right: 5px;
z-index: 1;
background-color: #ff0000;
border-left: 0;
border-right: 1px solid #000000;
border-top: 0.5px solid #000000;
border-bottom: 0.5px solid #000000;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
.addon.hidden {
display: none;
}
.addon+.addon {
right: 10px;
padding-right: 10px;
}
<section class="container">
<div class="content">This is shown correctly (no addons)</div>
</section>
<section class="container">
<div class="content">This is shown correctly (one addon)</div>
<aside class="addon visible"></aside>
</section>
<section class="container">
<div class="content">
This is shown correctly (multiple addons, one is hidden)
</div>
<aside class="addon hidden"></aside>
<aside class="addon visible"></aside>
</section>
<section class="container">
<div class="content">This is shown correctly (multiple addons)</div>
<aside class="addon visible"></aside>
<aside class="addon visible"></aside>
</section>
<section class="container">
<div class="content">This should have all rounded borders</div>
<aside class="addon hidden"></aside>
</section>
<section class="container">
<div class="content">This should have all rounded borders</div>
<aside class="addon visible"></aside>
<aside class="addon hidden"></aside>
</section>
The code below shows what I have but it is not user friendly way to show data(time). "display:inline-block" puts elements in a row and after it reaches parent div's width it puts his next child in the next row.
.rateDates {
display: inline-block;
margin: 10px;
font-family: consolas;
border: 1px solid #73d5e6;
border-radius: 15px;
padding: 4px 8px 4px 8px;
}
#ratesContainer {
border: 1px solid #73d5e6;
padding: 15px;
border-radius: 10px;
margin-top: 20px;
margin-bottom: 20px;
height:200px;
}
<div id="ratesContainer">
<div class="rateDates">
<span>00:00:00</span>
</div>
<div class="rateDates">
<span>11:11:11</span>
</div>
<div class="rateDates">
<span>22:22:22</span>
</div>
<div class="rateDates">
<span>33:33:33</span>
</div>
<div class="rateDates">
<span>44:44:44</span>
</div>
<div class="rateDates">
<span>55:55:55</span>
</div>
</div>
The problem is I can't make it place child div's on top of each other and after the parent div's height is not enaugh start from top again. In other words start a new column.
I want to place rateDates class divs in column way. So they first fill up not the row but the column.
Page renders automatycally. I need a CSS solution. If it is posible.
Thank you.
use a flex property.
Here is updated code.
CSS
.rateDates {
margin: 10px;
font-family: consolas;
border: 1px solid #73d5e6;
border-radius: 15px;
padding: 4px 8px 4px 8px;
}
#ratesContainer {
border: 1px solid #73d5e6;
padding: 15px;
border-radius: 10px;
margin-top: 20px;
margin-bottom: 20px;
height:200px;
display:flex;
flex-direction:column;
flex-wrap:wrap
}
HTML
<div id="ratesContainer">
<div class="rateDates">
<span>00:00:00</span>
</div>
<div class="rateDates">
<span>11:11:11</span>
</div>
<div class="rateDates">
<span>22:22:22</span>
</div>
<div class="rateDates">
<span>33:33:33</span>
</div>
<div class="rateDates">
<span>44:44:44</span>
</div>
<div class="rateDates">
<span>55:55:55</span>
</div>
</div>
You can do it the Flexbox:
#ratesContainer {
display: flex; /* displays flex-items (children) inline */
border: 1px solid #73d5e6;
padding: 15px;
border-radius: 10px;
margin: 20px 0;
}
#ratesContainer > .rateDates {
flex: 1;
text-align: center;
margin: 10px;
font-family: consolas;
border: 1px solid #73d5e6;
border-radius: 15px;
padding: 4px 8px;
}
#media (max-width: 768px) { /* adjust */
#ratesContainer {
flex-direction: column; /* stacks children vertically */
align-items: center; /* because of the changed direction this is now horizontal centering, otherwise it's vertical by default */
}
}
<div id="ratesContainer">
<div class="rateDates">
<span>00:00:00</span>
</div>
<div class="rateDates">
<span>11:11:11</span>
</div>
<div class="rateDates">
<span>22:22:22</span>
</div>
<div class="rateDates">
<span>33:33:33</span>
</div>
<div class="rateDates">
<span>44:44:44</span>
</div>
<div class="rateDates">
<span>55:55:55</span>
</div>
</div>
It's a bit different approach but the end result is what you want, i.e. display them in one column vertically.
Just to mention an alternative approach, this can be also done with multi-column layout:
.rateDates {
display: inline-block;
margin: 10px;
font-family: consolas;
border: 1px solid #73d5e6;
border-radius: 15px;
padding: 4px 8px 4px 8px;
}
#ratesContainer {
border: 1px solid #73d5e6;
padding: 15px;
border-radius: 10px;
margin-top: 20px;
margin-bottom: 20px;
height:200px;
column-width: 110px;
column-fill: auto;
}
<div id="ratesContainer">
<div class="rateDates">
<span>00:00:00</span>
</div>
<div class="rateDates">
<span>11:11:11</span>
</div>
<div class="rateDates">
<span>22:22:22</span>
</div>
<div class="rateDates">
<span>33:33:33</span>
</div>
<div class="rateDates">
<span>44:44:44</span>
</div>
<div class="rateDates">
<span>55:55:55</span>
</div>
</div>
But I prefer the Flexbox solution. These items don't look like parts of the text flow, that inline-block was designed for. And with Flexbox you will not need to hardcode the width of the column.
I'm trying to make a simple front page but suddenly I can't move my background anymore. Tried it with padding but I can't solve it. Maybe it is because I just started with codes, haha! So what I wanna do is as follows: I want to move my container> background-color: rgba(98, 97, 99, 0.25); more to the center so that it's even on both sides. For some reason the code doesn't show up correctly in here but for me it is. Maybe because I'm using Bootstrap.
body html {
margin: 0;
padding: 0;
}
.container {
background-color: rgba(98, 97, 99, 0.25);
padding-top: 4%;
}
.wrap{
width: 1090px;
}
video {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
min-width: 100%;
min-height: 100%;
z-index: -100;
}
.wowImg {
height: 255px;
width: 255px;
border-top: solid black 9px;
border-bottom: solid black 9px;
border-left: solid black 9px;
float: left;
}
.venom {
height: 255px;
width: 255px;
border-bottom: solid black 9px;
border-left: solid black 9px;
float: left;
}
.overwatch {
height: 255px;
width: 255px;
border-top: solid black 9px;
border-bottom: solid black 9px;
border-right: solid black 9px;
border-left: solid black 9px;
float: left;
}
.sum41 {
height: 255px;
width: 255px;
border-bottom: solid black 9px;
border-right: solid black 9px;
border-left: solid black 9px;
float: left;
}
.middle {
height: 510px;
width: 550px;
border-top: solid black 9px;
border-bottom: solid black 9px;
border-left: solid black 9px;
float: left;
}
.whileSheSleeps {
height: auto;
width: 540px;
border-bottom: solid black 9px;
border-left: solid black 9px;
border-right: solid black 9px;
float: left;
}
.monster {
height: 284px;
width: 250px;
border-bottom: solid black 9px;
border-left: solid black 9px;
border-right: solid black 9px;
float: left;
}
.css_awesome {
height: 284px;
width: 285px;
border-bottom: solid black 9px;
border-left: solid black 9px;
border-right: solid black 9px;
float: left;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>homepage</title>
<link href="index.css" rel="stylesheet">
<link href="css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row col-md-12 wrap">
<div class="row">
<div class="col-md-12">
<div class="wrap">
<div class="row col-md-3 upperLeft">
<div class="row">
<div class="col-md-12">
<img class="wowImg"img">
<img class="venom" src="img">
</div>
</div>
</div>
<div class="col-md-6 Middle">
<div class="row">
<div class="col-md-12">
<img class="middle" src "img">
</div>
</div>
</div>
<div class="row col-md-3 upperRight">
<div class="row">
<div class="col-md-12">
<img class="overwatch" src="img">
<img class="sum41" src="img">
</div>
</div>
</div>
<div class="row col-md-6 bottomLeft">
<div class="row">
<div class="col-md-12">
<img class="whileSheSleeps" src="img">
</div>
</div>
</div>
<div class="row col-md-3 bottomMid">
<div class="row">
<div class="col-md-12">
<img class="monster" src="img">
</div>
</div>
</div>
<div class="row col-md-3 bottomRight">
<div class="row">
<div class="col-md-12">
<img class="css_awesome" src="img">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
.container {
background-color: rgba(98, 97, 99, 0.25);
padding-top: 4%;
width: 960px;
margin: 0 auto;
}
Set the container width and then left and right margin: auto;
.container {
background-color: rgba(98, 97, 99, 0.25);
padding-top: 4%;
width: 900px;
margin-left: auto;
margin-right: auto;
}
Add container float:left in css or you can add clear both
body html {
margin: 0;
padding: 0;
}
.container {
background-color: rgba(98, 97, 99, 0.25);
padding-top: 4%;
float:left;
}
.wrap{
width: 1090px;
}
video {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
min-width: 100%;
min-height: 100%;
z-index: -100;
}
.wowImg {
height: 255px;
width: 255px;
border-top: solid black 9px;
border-bottom: solid black 9px;
border-left: solid black 9px;
float: left;
}
.venom {
height: 255px;
width: 255px;
border-bottom: solid black 9px;
border-left: solid black 9px;
float: left;
}
.overwatch {
height: 255px;
width: 255px;
border-top: solid black 9px;
border-bottom: solid black 9px;
border-right: solid black 9px;
border-left: solid black 9px;
float: left;
}
.sum41 {
height: 255px;
width: 255px;
border-bottom: solid black 9px;
border-right: solid black 9px;
border-left: solid black 9px;
float: left;
}
.middle {
height: 510px;
width: 550px;
border-top: solid black 9px;
border-bottom: solid black 9px;
border-left: solid black 9px;
float: left;
}
.whileSheSleeps {
height: auto;
width: 540px;
border-bottom: solid black 9px;
border-left: solid black 9px;
border-right: solid black 9px;
float: left;
}
.monster {
height: 284px;
width: 250px;
border-bottom: solid black 9px;
border-left: solid black 9px;
border-right: solid black 9px;
float: left;
}
.css_awesome {
height: 284px;
width: 285px;
border-bottom: solid black 9px;
border-left: solid black 9px;
border-right: solid black 9px;
float: left;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>homepage</title>
<link href="index.css" rel="stylesheet">
<link href="css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row col-md-12 wrap">
<div class="row">
<div class="col-md-12">
<div class="wrap">
<div class="row col-md-3 upperLeft">
<div class="row">
<div class="col-md-12">
<img class="wowImg"img">
<img class="venom" src="img">
</div>
</div>
</div>
<div class="col-md-6 Middle">
<div class="row">
<div class="col-md-12">
<img class="middle" src "img">
</div>
</div>
</div>
<div class="row col-md-3 upperRight">
<div class="row">
<div class="col-md-12">
<img class="overwatch" src="img">
<img class="sum41" src="img">
</div>
</div>
</div>
<div class="row col-md-6 bottomLeft">
<div class="row">
<div class="col-md-12">
<img class="whileSheSleeps" src="img">
</div>
</div>
</div>
<div class="row col-md-3 bottomMid">
<div class="row">
<div class="col-md-12">
<img class="monster" src="img">
</div>
</div>
</div>
<div class="row col-md-3 bottomRight">
<div class="row">
<div class="col-md-12">
<img class="css_awesome" src="img">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Problem 1: I'm trying to get my div boxes to have the same width regardless from text length I use (I will use max 2 digits), but I can't get it to work.
Problem 2: The target platform is mobile and when the linewraping occurs the "boxes" positions right under the text from the text on the line above (the borders crosses each other).
The reson for using div "groups" is that a javascript is going to change the value of 4 boxes at a time.
<!DOCTYPE html>
<html>
<head>
<style>
.wrap {
white-space: normal !important;
}
.online {
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border: 2px solid #00CC00;
width: 20px;
text-align: center;
padding: 2px;
display: inline;
}
.test {
display: inline;
}
</style>
</head>
<body>
<div id="A1-result" class="test">
<div class="online">0</div>
<div class="online">1</div>
<div class="online">2</div>
<div class="online">3</div>
</div>
<div id="A2-result" class="test">
<div class="online">4</div>
<div class="online">5</div>
<div class="online">6</div>
<div class="online">7</div>
</div>
<div id="A3-result" class="test">
<div class="online">8</div>
<div class="online">9</div>
<div class="online">10</div>
<div class="online">11</div>
</div>
<div id="A4-result" class="test">
<div class="online">12</div>
<div class="online">13</div>
<div class="online">14</div>
<div class="online">15</div>
</div>
</body>
</html>
Change display:inline property to display:inline-block. Read more about the difference between inline and inline-block.
.online {
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border: 2px solid #00CC00;
width: 20px;
text-align: center;
padding: 2px;
display: inline-block;
}
.test {
display: inline-block;
}
DEMO