I have a "posts__box" ("Davi Jesus" section) that is floating far to the right even with a "posts__box--left" class ("float: left"). HTML is fine, CSS is fine, I'm freaking out 'cause I can't understand why the heck this is happening.
btw: "revista" means "magazine" and it's my first time trying to apply BEM methodoly. I'm a newbie webdesigner.
Images:
.posts {
width: 100%;
}
.container {
float: left;
width: 80%;
height: 1400px;
margin: 0 135px;
padding: 0;
background: #ffffff;
}
.box--btn {
margin-top: 10px;
border: 1.5px solid black;
box-shadow: 2px 2px 2px dimgray;
}
.posts__box {
margin-top: 40px;
margin-left: 20px;
width: 30%;
}
.box--title {
text-align: center;
}
.box--img {
width: 100%;
box-shadow: 3px 3px 3px Dimgray;
}
.box--text {
padding: 5px;
}
.box--author {
float: right;
width: 46%;
height: 50px;
}
.box--author--text {
margin-top: 10px;
margin-left: 6px;
}
.box--continue {
float: left;
width: 46%;
height: 50px;
}
.box--continue--text {
margin-top: 12px;
margin-left: 7px;
}
.posts__btns {
float: left;
margin-top: 20px;
width: 100%;
height: 200px;
}
/* MODIFIERS */
.revista__posts--height {
height: 3000px;
}
/* posts */
.title--red {
color: rgba(233, 26, 26, 1);
}
.title--size-small {
font-size: 30px;
text-shadow: 1.5px 1.5px black;
}
.title--size-large {
font-size: 60px;
text-shadow: 3px 3px black;
}
.box--btn--red {
background: rgba(233, 26, 26, 1);
}
.continue--white {
color: #ffffff;
text-shadow: 1.5px 1.5px black;
}
.box--btn--black {
background: #212121;
}
.author--white {
color: #ffffff;
text-shadow: 2px 2px black;
}
.posts__box--left {
float: left;
}
.posts__box--right {
float: right;
}
.posts__box--margin--fix--left {
margin-top: 10px;
margin-left: 40px;
}
.posts__box--margin--fix--top {
margin-top: 34px;
margin-left: 40px;
}
.posts__btns--left {
float: left;
margin-left: 20px;
}
.posts__btns--right {
float: right;
margin-right: 20px;
}
/* revista */
.container__border {
border-top: 4px solid black;
border-left: 4px solid black;
border-right: 4px solid black;
}
.revista__container--height {
height: 4800px;
}
<article class="posts">
<section class="container revista__container--height container__border">
<!-- davi jesus -->
<section class="posts__box posts__box--left">
<div class="box--title">
<a class="title--red --hover" href="..\revista\artistas\davi-jesus.html">
<h1 class="title--size-small --hover--darkred">Davi de Jesus do Nascimento:<br> corpo de rio</h1>
</a>
</div>
<div>
<a href="..\revista\artistas\davi-jesus.html">
<img class="box--img" src="..\_img\posts\davi-de-jesus\instax\6.png" alt="">
</a>
</div>
<div class="box--continue box--btn box--btn--red">
<a class="--hover" href="..\revista\artistas\davi-jesus.html">
<h5 class="box--continue--text continue--white -font--very-small --hover--dimgray">CONTINUAR A LEITURA</h5>
</a>
</div>
<div class="box--author box--btn box--btn--black">
<a class="--hover" href="..\revista\artistas\daniel-jesus.html">
<h2 class="box--author--text author--white -font--small --hover--dimgray">Davi Jesus</h2>
</a>
</div>
</section>
I just fixed it with a simple "clear: left" class. I guess it was just some weird bug or something like that. If someone has a different explanation and could share with us, I would appreciate. Thanks!
Related
I'm trying to make a google clone page, I am trying to make the footer to be sticked to the end of the viewport. But when I try position: absolute bottom: 0, it sticks to the end, but the page overflows.
I tried to use html, body and * height: 100% but it doesn't work.
I share my github repository for you to check the code: https://github.com/Diefonro/HTML-CSS
You can also check the webpage (on a PC) at: https://diefonro.github.io/HTML-CSS/
Code:
<body>
<header>
<nav>
<div class="nav">
<div id="nav-g-i">
<a class="menu-item" href="#">Gmail</a>
<a class="menu-item" href="https://google.com/imghp">Images</a>
</div>
<div class="" id="nav-gr-a">
<div class="dd-cont">
<div class="grid">
<img
id="grid"
src="assets/icons/apps_black_24dp.svg"
alt="apps-icon"
/>
</div>
<div class="drop-d">
<div class="dd-item">
<img
id="dd-search"
src="assets/icons/google-logo-dd.png"
alt="google-search-icon"
/>
<p>Search</p>
</div>
<div class="dd-item">
<img
id="dd-maps"
src="assets/icons/google-maps-dd.png"
alt="google-maps-icon"
/>
<p>Maps</p>
</div>
<div class="dd-item">
<img
id="dd-keep"
src="assets/icons/google-keep-dd.png"
alt="google-keep-icon"
/>
<p>Keep</p>
</div>
<div class="dd-item">
<img
class="dd-drive"
src="assets/icons/Google_Drive_dd.png"
alt="google-keep-icon"
/>
<p>Drive</p>
</div>
<div class="dd-item">
<img
class="dd-calendar"
src="assets/icons/512px-Google_Calendar_icon_dd.png"
alt="google-calendar-icon"
/>
<p>Calendar</p>
</div>
<div class="dd-item">
<img
class="dd-photos"
src="assets/icons/google_photos-dd.png"
alt="google-photos-icon"
/>
<p>Photos</p>
</div>
</div>
</div>
<img
id="profile-pic"
src="assets/icons/account_circle_black_24dp.svg"
alt="account-icon"
/>
</div>
</div>
</nav>
</header>
<main>
<section>
<div class="logo-cont">
<img
id="google-logo"
src="assets/images/googlelogo_color_272x92dp.png"
alt="google-logo"
/>
</div>
<div class="input-cont">
<input class="input-g" type="text" />
<img
src="assets/icons/search_black_24dp.svg"
alt="search-icon"
class="search-i"
/>
<img
class="mic"
src="assets/icons/Google_mic.svg.png"
alt="voice-search-icon"
/>
</div>
<div class="btn-cont">
<button class="custom-btn">Google Search</button>
<button class="custom-btn custom-btn-l">I'm Feeling Lucky</button>
</div>
<span class="s-lang"
>Google offered in:
<a href="#" class="s-link"
><div class="ll">Español (Latinoamérica)</div></a
>
</span>
</section>
</main>
<footer>
<div class="footer-cont">
<div class="top-footer">
<span class="f1">Colombiac test</span>
</div>
<div class="bottom-footer">
<div class="left-footer">
<div class="a-li">
About
Advertising
Business
How Search works
</div>
</div>
<div class="right-footer">
Privacy
Terms
Settings
</div>
</div>
</div>
</footer>
</body>
* {
margin: 0;
}
html{
height: 100vh;
}
body {
font-family: Arial, sans-serif;
}
nav {
text-align: right;
position: relative;
top: 9px;
right: 8px;
}
#nav-g-i {
display: inline-block;
position: relative;
top: 2px;
right: 23px;
}
#nav-gr-a {
display: inline-block;
position: relative;
top: 5px;
right: 10px;
}
#grid,
#profile-pic {
opacity: 50%;
}
section {
text-align: center;
position: relative;
top: 24px;
}
.input-g {
position: relative;
bottom: 2px;
width: 500px;
line-height: 17px;
border: none;
outline: none;
}
.input-cont {
width: 553px;
height: 16px;
position: relative;
bottom: 2px;
right: 1px;
color: #222;
border: 1px solid #dfe1e5;
font-size: 13px;
padding: 14px;
border-radius: 80px;
margin: 24px 0px;
display: inline-block;
}
.input-cont:hover,
.input-cont:focus {
box-shadow: 0 1px 5px 0 rgba(32, 33, 36, 0.28);
border-color: rgba(40, 40, 41, 0);
}
.input-cont > img {
position: absolute;
top: 10px;
right: 11px;
width: 23px;
}
.input-cont .search-i {
position: absolute;
top: 11.5px;
right: 547px;
width: 20px;
opacity: 40%;
}
#grid {
position: relative;
bottom: 3px;
margin-right: 16px;
}
.menu-item {
font-size: 13px;
color: #5b5f63;
text-decoration: none;
position: relative;
bottom: 8px;
margin-right: 10px;
}
.menu-item:hover {
text-decoration: underline;
}
#profile-pic {
width: 32px;
height: 32px;
}
.btn-cont {
position: relative;
top: 3px;
}
.custom-btn {
background-color: #f2f2f291;
color: #a2a8af;
font-size: 14px;
height: 36px;
padding: 0 16px;
background-image: linear-gradient(top, #f5f5f5, #f1f1f1);
border: 1px solid transparent;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0);
color: #222;
border-radius: 5px;
}
.custom-btn:first-of-type {
margin-right: 7px;
}
.custom-btn:hover {
border: 1px solid #c6c6c656;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
color: #222;
}
.custom-btn:active {
border: 1px solid cornflowerblue;
}
.drop-d {
width: 285px;
padding: 10px;
border: 1px solid #ccc;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
text-align: center;
position: absolute;
right: 11px;
border-radius: 12px;
display: none;
}
.grid:hover {
display: inline-block;
}
.dd-item:hover {
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 8px;
}
.dd-item {
margin-top: 10px;
display: inline-block;
width: 70px;
padding: 6px 3px;
}
.dd-item > img {
height: 50px;
width: 50px;
}
.dd-item > p {
color: rgba(0, 0, 0, 0.87);
margin: 0;
margin-top: 15px;
margin-bottom: 5px;
}
.dd-cont {
display: inline-block;
}
.dd-cont:hover .drop-d {
display: block;
}
.s-lang {
font-size: 13px;
color: #333;
position: relative;
top: 30px;
right: 3px;
}
.s-lang a {
text-decoration: underline;
}
.s-lang a:visited {
color: rgb(30, 30, 179);
}
.ll {
display: inline-block;
position: relative;
left: 3px;
}
.top-footer,
.bottom-footer {
font-size: 15px;
background-color: #d6d8da49;
color: #8a8686;
position: relative;
top: 200px;
}
.top-footer{
border-bottom: 1px solid rgba(155, 155, 155, 0.267);
}
.left-footer a {
display: inline-block;
text-decoration: none;
padding: 12px;
font-size: 14px;
}
.right-footer a {
font-size: 14px;
padding: 14px;
text-decoration: none;
color: #8a8686;
}
.bottom-footer{
display: flex;
justify-content: space-between;
align-items: center;
}
.bottom-footer a:hover{
text-decoration: underline;
}
span.f1 {
display: inline-block;
margin-left: 15px;
padding: 16px;
}
.a-li {
margin-left: 20px;
}
a:visited {
color: inherit;
}
.footer-cont {
position: absolute;
bottom: 0;
width: 100%;
left: 0;
height: fit-content;
height: -moz-fit-content;
}
footer{
position: relative;
width: 100vw;
}
You can remove top: 200px on .top-footer, .bottom-footer. Why? because you have added bottom: 0 to .footer-cont which increases its position to 0 (.footer-cont) + 200px (.top-footer, .bottom-footer) = 200px down. If scroll bars in vertical bother you, you can add overflow-y: hidden style to body or html.
I am busy prototyping a layout using bootstrap and some custom css. I have a div with container-fluid and then two rows. 1st row has three columns within and second row just has a full width div in it.
All is good until I reduce the window size and a break-point is reached and the design becomes responsive which is fine other than the second row with the full width div seems to float over the 1st row elements instead of staying at the bottom.
How do I get the 2nd row to stay pinned to the bottom when in a smaller client size.
Note that the 1st row is setup to expand and fill the remaining height of the screen, the 2nd row is a fixed 50px in height.
Bootstrap taken from https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/
Screen grabs of effect (HTML after)
HTML template
#import url('https://fonts.googleapis.com/css?family=Roboto&display=swap');
html,
body {
height: 100%;
margin: 0;
font-family: 'Roboto', sans-serif;
background-color: #dedee1;
}
#ctr-main {
height: 100%;
min-height: 100%;
display: flex;
flex-direction: column;
}
.red-border {
border: 1px red solid;
}
.blue-border {
border: 1px blue solid;
}
.panel {
width: 100%;
background-color: rgba(218, 226, 254, 0.63);
margin-top: 5px;
overflow: hidden;
}
#panel-ticket-tabs {
height: 50px;
}
#panel-ticket-meta {
height: 100px;
}
#panel-status {
height: 150px;
}
#panel-customer-info {
height: 150px;
}
#panel-customer-history {
height: 250px;
}
#panel-customer-shortcuts {
height: 250px;
}
#panel-ticket {
/*height:500px;*/
flex-grow: 1;
}
#panel-channels {
height: 500px;
}
#panel-tools {
/*flex-grow: 1;*/
}
#panel-bottom-bar {
width: 100%;
height: 50px;
background-color: #2e57cc;
display: block;
position: relative;
text-align: left;
}
.pnl-title {
width: 100%;
height: 25px;
vertical-align: middle;
color: white;
font-size: 1em;
font-weight: bold;
background-color: #2e57cc;
overflow: hidden;
line-height: 25px;
padding-left: 5px;
/*! border-bottom: 2px solid #22366f; */
}
.row-flex {
flex: 1;
}
.column-flex {
display: flex;
flex-flow: column;
height: 100%;
}
.panel-height-filler {
display: flex;
flex-flow: column;
height: 100%;
flex: 1 1 auto;
}
.pnl-round-corner-bottom {
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
.pnl-round-corner {
border-radius: 10px;
}
.pnl-square {
border-radius: 0;
}
.pnl-border {
border: 1px solid #000335;
}
.pnlSection {
background-color: #fff;
width:98%;
min-height:25px;
margin: 0 auto;
z-index: 20;
}
.pnlSection-border {
border:1px solid black;
}
#pnlSection-user-tabs {
background-color: transparent;
z-index: 25;
}
#pnlSection-channels {
margin-top: -1px;
}
.tabButton {
display:inline-block;
border-radius: 5px 5px 0 0;
background-color: #d6d6d6;
height: 30px;
width: 100px;
border-top: 1px solid black;
border-left: 1px solid black;
border-right: 1px solid black;
line-height: 30px;
border-bottom: 1px solid black;
}
.tabButton > span {
display:block;
font-weight: bold;
color:black;
font-size:12px;
padding:0;
margin:auto 0;
/*! line-height: normal; */
text-align: center;
}
.tabButton:hover {
background-color: #ffffff;
cursor: pointer;
}
#panel-bottom-bar > .icon-container {
color: white;
display: inline-block;
position: relative;
margin: 7px 0 auto .25em;
border: white 1px solid;
padding:2px;
border-radius: 5px;
overflow:hidden;
}
#panel-bottom-bar > .icon-container:hover {
background-color:white;
color:#2e57cc;
border-color:#2e57cc;
cursor:pointer;
}
#panel-bottom-bar > .icon-container.active {
background-color:white;
color:#2e57cc;
border-color:#2e57cc;
}
.activeTab {
background-color: white;
border-bottom: 0;
}
.alertTab {
background-color: #e57616;
}
.pnl-outer-shadow {
-webkit-box-shadow: 3px 3px 5px 6px #9c9c9c; /* Safari 3-4, iOS 4.0.2 - 4.2, Android 2.3+ */
-moz-box-shadow: 3px 3px 5px 6px #9c9c9c; /* Firefox 3.5 - 3.6 */
box-shadow: 3px 3px 5px 6px #9c9c9c; /* Opera 10.5, IE 9, Firefox 4+, Chrome 6+, iOS 5 */
}
.pnl-inner-shadow {
-moz-box-shadow: inset 0 0 10px #9c9c9c;
-webkit-box-shadow: inset 0 0 10px #9c9c9c;
box-shadow: inset 0 0 10px #9c9c9c;
}
.pnl-bend-shadow-bottom {
-webkit-box-shadow: 0 10px 6px -6px #777;
-moz-box-shadow: 0 10px 6px -6px #777;
box-shadow: 0 10px 6px -6px #777;
}
#ctr-main > div.container-fluid {
padding-left: 15px;
padding-right: 15px;
}
#column-left > div.row {
margin: 0 0 0 2px;
}
#column-middle > div.row {
margin: 0 2px 0 2px;
}
#column-right > div.row {
margin: 0 2px 0 0;
}
#column-left {
/*! vertical-align: top; */
/*! margin: auto; */
margin-top: 0;
padding-left: 5px;
}
#column-right {
padding-right: 5px;
}
#column-middle {
padding-left: 5px;
padding-right: 5px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Prototype1 - Main</title>
<!-- Styles and links to JS removed for clarity -->
</head>
<body>
<div id="ctr-main" class="container-fluid">
<div class="row row-flex">
<div class="col-sm-3 column-flex" id="column-left">
<div id="panel-status" class="panel pnl-round-corner-bottom pnl-border">
<h2 class="pnl-title">Console</h2>
</div>
<div id="panel-channels" class="panel panel-height-filler pnl-round-corner-bottom pnl-border">
<h2 class="pnl-title">Channel selector</h2>
<div id="pnlSection-user-tabs" class="pnlSection">
<div class="tabButton activeTab"><span>Customers</span></div>
<div class="tabButton alertTab"><span>Agents</span></div>
<div class="tabButton"><span>Administrators</span></div>
</div>
<div id="pnlSection-channels" class="pnlSection pnlSection-border">
</div>
</div>
</div>
<div class="col-sm-6 column-flex" id="column-middle">
<div id="panel-ticket" class="panel panel-height-filler pnl-round-corner-bottom pnl-border">
<h2 class="pnl-title">Ticket details</h2>
</div>
</div>
<div class="col-sm-3 column-flex" id="column-right">
<div id="panel-tools" class="panel panel-height-filler pnl-round-corner-bottom pnl-border">
<h2 class="pnl-title">Tools</h2>
</div>
</div>
</div>
<div class="row">
<div id="panel-bottom-bar" class="panel pnl-square pnl-border">
<div class="icon-container">
<span class="icon-home"></span>
</div>
</div>
</div>
</div>
</body>
</html>
Height 100% on column-flex won't work here. 100% of what ? that's the problem.
You should use auto so it takes the height of it's content because you set fixed heights on the panels .
You should add this in a media query.
See code below or -> JsFiddle
html,
body {
height: 100%;
margin: 0;
font-family: 'Roboto', sans-serif;
background-color: #dedee1;
}
#ctr-main {
height: 100%;
min-height: 100%;
display: flex;
flex-direction: column;
}
.red-border {
border: 1px red solid;
}
.blue-border {
border: 1px blue solid;
}
.panel {
width: 100%;
background-color: rgba(218, 226, 254, 0.63);
margin-top: 5px;
overflow: hidden;
}
#panel-ticket-tabs {
height: 50px;
}
#panel-ticket-meta {
height: 100px;
}
#panel-status {
height: 150px;
}
#panel-customer-info {
height: 150px;
}
#panel-customer-history {
height: 250px;
}
#panel-customer-shortcuts {
height: 250px;
}
#panel-ticket {
/*height:500px;*/
flex-grow: 1;
}
#panel-channels {
height: 500px;
}
#panel-tools {
/*flex-grow: 1;*/
}
#panel-bottom-bar {
width: 100%;
height: 50px;
background-color: #2e57cc;
display: block;
position: relative;
text-align: left;
}
.pnl-title {
width: 100%;
height: 25px;
vertical-align: middle;
color: white;
font-size: 1em;
font-weight: bold;
background-color: #2e57cc;
overflow: hidden;
line-height: 25px;
padding-left: 5px;
/*! border-bottom: 2px solid #22366f; */
}
.row-flex {
flex: 1;
}
.column-flex {
display: flex;
flex-flow: column;
height:100%
}
.panel-height-filler {
display: flex;
flex-flow: column;
height: 100%;
flex: 1 1 auto;
}
.pnl-round-corner-bottom {
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
.pnl-round-corner {
border-radius: 10px;
}
.pnl-square {
border-radius: 0;
}
.pnl-border {
border: 1px solid #000335;
}
.pnlSection {
background-color: #fff;
width:98%;
min-height:25px;
margin: 0 auto;
z-index: 20;
}
.pnlSection-border {
border:1px solid black;
}
#pnlSection-user-tabs {
background-color: transparent;
z-index: 25;
}
#pnlSection-channels {
margin-top: -1px;
}
.tabButton {
display:inline-block;
border-radius: 5px 5px 0 0;
background-color: #d6d6d6;
height: 30px;
width: 100px;
border-top: 1px solid black;
border-left: 1px solid black;
border-right: 1px solid black;
line-height: 30px;
border-bottom: 1px solid black;
}
.tabButton > span {
display:block;
font-weight: bold;
color:black;
font-size:12px;
padding:0;
margin:auto 0;
/*! line-height: normal; */
text-align: center;
}
.tabButton:hover {
background-color: #ffffff;
cursor: pointer;
}
#panel-bottom-bar > .icon-container {
color: white;
display: inline-block;
position: relative;
margin: 7px 0 auto .25em;
border: white 1px solid;
padding:2px;
border-radius: 5px;
overflow:hidden;
}
#panel-bottom-bar > .icon-container:hover {
background-color:white;
color:#2e57cc;
border-color:#2e57cc;
cursor:pointer;
}
#panel-bottom-bar > .icon-container.active {
background-color:white;
color:#2e57cc;
border-color:#2e57cc;
}
.activeTab {
background-color: white;
border-bottom: 0;
}
.alertTab {
background-color: #e57616;
}
.pnl-outer-shadow {
-webkit-box-shadow: 3px 3px 5px 6px #9c9c9c; /* Safari 3-4, iOS 4.0.2 - 4.2, Android 2.3+ */
-moz-box-shadow: 3px 3px 5px 6px #9c9c9c; /* Firefox 3.5 - 3.6 */
box-shadow: 3px 3px 5px 6px #9c9c9c; /* Opera 10.5, IE 9, Firefox 4+, Chrome 6+, iOS 5 */
}
.pnl-inner-shadow {
-moz-box-shadow: inset 0 0 10px #9c9c9c;
-webkit-box-shadow: inset 0 0 10px #9c9c9c;
box-shadow: inset 0 0 10px #9c9c9c;
}
.pnl-bend-shadow-bottom {
-webkit-box-shadow: 0 10px 6px -6px #777;
-moz-box-shadow: 0 10px 6px -6px #777;
box-shadow: 0 10px 6px -6px #777;
}
#ctr-main > div.container-fluid {
padding-left: 15px;
padding-right: 15px;
}
#column-left > div.row {
margin: 0 0 0 2px;
}
#column-middle > div.row {
margin: 0 2px 0 2px;
}
#column-right > div.row {
margin: 0 2px 0 0;
}
#column-left {
/*! vertical-align: top; */
/*! margin: auto; */
margin-top: 0;
padding-left: 5px;
}
#column-right {
padding-right: 5px;
}
#column-middle {
padding-left: 5px;
padding-right: 5px;
}
/* add breakpoint */
#media only screen(max-width:550px) {
.column-flex {
height:auto;
min-height:100vh;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" rel="stylesheet"/>
<div id="ctr-main" class="container-fluid">
<div class="row row-flex">
<div class="col-sm-3 column-flex" id="column-left">
<div id="panel-status" class="panel pnl-round-corner-bottom pnl-border">
<h2 class="pnl-title">Console</h2>
</div>
<div id="panel-channels" class="panel panel-height-filler pnl-round-corner-bottom pnl-border">
<h2 class="pnl-title">Channel selector</h2>
<div id="pnlSection-user-tabs" class="pnlSection">
<div class="tabButton activeTab"><span>Customers</span></div>
<div class="tabButton alertTab"><span>Agents</span></div>
<div class="tabButton"><span>Administrators</span></div>
</div>
<div id="pnlSection-channels" class="pnlSection pnlSection-border">
</div>
</div>
</div>
<div class="col-sm-6 column-flex" id="column-middle">
<div id="panel-ticket" class="panel panel-height-filler pnl-round-corner-bottom pnl-border">
<h2 class="pnl-title">Ticket details</h2>
</div>
</div>
<div class="col-sm-3 column-flex" id="column-right">
<div id="panel-tools" class="panel panel-height-filler pnl-round-corner-bottom pnl-border">
<h2 class="pnl-title">Tools</h2>
</div>
</div>
</div>
<div class="row">
<div id="panel-bottom-bar" class="panel pnl-square pnl-border">
<div class="icon-container">
<span class="icon-home"></span>
</div>
</div>
</div>
</div>
I'm doing some mvc testing and I've hit a roadblock when I'm going through my model to display some elements. Each element will have to have an "EXP" amount that is displayed dynamically in the ::after element in the css.
Is there a way to dynamically change the width of the ::after element? I am passing through the width for each element through the model but I don't display it yet
That's the bar that needs to change dynamically, here's an example piece of code of how I've done it so far:
.pkmn-pc {
color: white;
margin: 10px;
display: inline-block;
}
.pkmn-summary, .pkmn-info {
display: table-cell;
vertical-align: middle;
height: 60px;
}
.pkmn-summary {
width: 193px;
background: #745fb5;
background: linear-gradient(15deg, #745fb5, #9a6dbb);
border-radius: 5px 0 0 5px;
box-shadow: 0 1px 1px rgba(102, 119, 136, 0.55);
white-space: nowrap;
border-bottom: solid 5px grey;
text-align: left;
padding-left: 5px;
}
.pkmn-summary:after {
content: '';
position: relative;
left: -181px;
bottom: -31px;
height: 5px;
background: green;
width: 73%;
display: inline-block;
border-radius: 0 0 0 5px;
}
.pkmn-info {
background: #333538;
border-radius: 0 5px 5px 0;
width: 70px;
text-align: center;
box-shadow: 0 1px 1px rgba(102, 119, 136, 0.55);
}
.pkmn-outer {
padding-bottom: 2px;
}
.pkmn-inner {
display: inline-block;
width: 3px;
}
.pkmn-sprite {
vertical-align: middle;
}
.pkmn-name {
font-size: 1.2em;
}
.pkmn-lvl {
font-size: 0.8em;
display: block;
}
.crown {
padding-top: 5px;
}
code {
padding: 0;
font-size: 1em;
color: white;
background-color: transparent;
border-radius: 0;
}
<div class="pkmn-pc">
<div class="pkmn-summary">
<img class="pkmn-sprite" src="https://cdn.bulbagarden.net/upload/e/ea/113MS.png" />
<code class="pkmn-name">15Characterssss</code>
</div>
<div class="pkmn-info">
<img class="crown" src="https://cdn.bulbagarden.net/upload/c/c5/Leaf_Crown_Sprite.png" />
<div class="pkmn-outer">
<img class="heart" src="https://image.ibb.co/kB8vi6/heart.png">
<div class="pkmn-inner"></div>
<img class="star" src="https://image.ibb.co/e7w4bR/Shiny_VIStar.png">
</div>
<code class="pkmn-lvl">lvl 100</code>
</div>
</div>
Any help would be greatly appreciated! Thanks!
If you have the EXP value available in the data (along with the other user info), you could create an element (we'll call it .pkmn-exp) and set the experience level (or width) in an inline style.
For example, if the user has an experience level of 73/100:
<div class="pkmn-exp" style="width:73%;"></div>
where the 73 comes from the user's data.
.pkmn-pc {
color: white;
margin: 10px;
display: inline-block;
}
.pkmn-summary,
.pkmn-info {
display: table-cell;
vertical-align: middle;
height: 60px;
}
.pkmn-summary {
position: relative;
width: 193px;
background: #745fb5;
background: linear-gradient(15deg, #745fb5, #9a6dbb);
border-radius: 5px 0 0 5px;
box-shadow: 0 1px 1px rgba(102, 119, 136, 0.55);
white-space: nowrap;
border-bottom: solid 5px grey;
text-align: left;
padding-left: 5px;
}
.pkmn-exp {
position: absolute;
left: 0px;
bottom: -5px;
height: 5px;
background: green;
display: inline-block;
border-radius: 0 0 0 5px;
}
.pkmn-info {
background: #333538;
border-radius: 0 5px 5px 0;
width: 70px;
text-align: center;
box-shadow: 0 1px 1px rgba(102, 119, 136, 0.55);
}
.pkmn-outer {
padding-bottom: 2px;
}
.pkmn-inner {
display: inline-block;
width: 3px;
}
.pkmn-sprite {
vertical-align: middle;
}
.pkmn-name {
font-size: 1.2em;
}
.pkmn-lvl {
font-size: 0.8em;
display: block;
}
.crown {
padding-top: 5px;
}
code {
padding: 0;
font-size: 1em;
color: white;
background-color: transparent;
border-radius: 0;
}
<div class="pkmn-pc">
<div class="pkmn-summary">
<img class="pkmn-sprite" src="https://cdn.bulbagarden.net/upload/e/ea/113MS.png" />
<code class="pkmn-name">15Characterssss</code>
<div class="pkmn-exp" style="width:73%"></div>
</div>
<div class="pkmn-info">
<img class="crown" src="https://cdn.bulbagarden.net/upload/c/c5/Leaf_Crown_Sprite.png" />
<div class="pkmn-outer">
<img class="heart" src="https://image.ibb.co/kB8vi6/heart.png">
<div class="pkmn-inner"></div>
<img class="star" src="https://image.ibb.co/e7w4bR/Shiny_VIStar.png">
</div>
<code class="pkmn-lvl">lvl 100</code>
</div>
</div>
Unfortunately you cannot script the ::after elements as they are not part of the dom.
You could either
Use a set of predefined classes and apply them to parent
add a bar element and script it like
var p = 0;
var bar = document.querySelector(".pkmn-bar");
window.setInterval(function() {
bar.style.width=p+"%";
p++;
if(p>100) p=0;
},50);
.pkmn-pc {
color: white;
margin: 10px;
display: inline-block;
}
.pkmn-summary, .pkmn-info {
display: table-cell;
vertical-align: middle;
height: 60px;
}
.pkmn-summary {
width: 193px;
background: #745fb5;
background: linear-gradient(15deg, #745fb5, #9a6dbb);
border-radius: 5px 0 0 5px;
box-shadow: 0 1px 1px rgba(102, 119, 136, 0.55);
white-space: nowrap;
border-bottom: solid 5px grey;
text-align: left;
padding-left: 5px;
position: relative;
}
.pkmn-bar {
content: '';
background: #745fb5;
white-space: nowrap;
text-align: left;
position: absolute;
left: 0;
bottom: -5px;
height: 5px;
background: green;
display: block;
border-radius: 0 0 0 5px;
}
.pkmn-info {
background: #333538;
border-radius: 0 5px 5px 0;
width: 70px;
text-align: center;
box-shadow: 0 1px 1px rgba(102, 119, 136, 0.55);
}
.pkmn-outer {
padding-bottom: 2px;
}
.pkmn-inner {
display: inline-block;
width: 3px;
}
.pkmn-sprite {
vertical-align: middle;
}
.pkmn-name {
font-size: 1.2em;
}
.pkmn-lvl {
font-size: 0.8em;
display: block;
}
.crown {
padding-top: 5px;
}
code {
padding: 0;
font-size: 1em;
color: white;
background-color: transparent;
border-radius: 0;
}
<div class="pkmn-pc">
<div class="pkmn-summary">
<img class="pkmn-sprite" src="https://cdn.bulbagarden.net/upload/e/ea/113MS.png" />
<code class="pkmn-name">15Characterssss</code>
<div class="pkmn-bar"></div>
</div>
<div class="pkmn-info">
<img class="crown" src="https://cdn.bulbagarden.net/upload/c/c5/Leaf_Crown_Sprite.png" />
<div class="pkmn-outer">
<img class="heart" src="https://image.ibb.co/kB8vi6/heart.png">
<div class="pkmn-inner"></div>
<img class="star" src="https://image.ibb.co/e7w4bR/Shiny_VIStar.png">
</div>
<code class="pkmn-lvl">lvl 100</code>
</div>
</div>
I have following html for my site:
Edit: https://jsfiddle.net/3v66fv3u/1/ for the static site
and my approach of making the site responsive: https://jsfiddle.net/wba321bm/
<!DOCTYPE html>
<html>
<head>
<link href="custom.css" rel="stylesheet">
</head>
<body>
<h1 class="title">Headline</h1>
<div class="wrapper">
<div class="left">
<div class="top">
<img id="img_1" src="img_1.png">
</div>
<div class="bottom">
<img id="img_3" src="img_3.png">
</div>
</div>
<div class="middle">
<div class="about-text">
<h3>small headline</h3>
<p>actually a lot of text</p>
</div>
</div>
<div class="right">
<div class="top">
<img id="img_2" src="img_2.png">
</div>
<div class="bottom">
<img id="img_4" src="img_4.png">
</div>
</div>
</div>
<img class="banner" src="banner.png"/>
</body>
</html>
And this is my current css file:
html {
font-family: "Verdana", Geneva, sans-serif;
color: white;
}
body {
margin: auto;
background-color: black;
width: 1150px;
}
hr {
border-top: 1px dotted black;
}
.title {
text-align: center;
padding-bottom: 20px;
}
.wrapper {
margin: auto;
}
.left {
float: left;
}
.middle {
height: 597px;
width: 550px;
float: left;
border-top: 1px solid white;
border-bottom: 1px solid white;
box-shadow: inset 0px 0px 20px 0px rgba(0,0,0,1);
margin-top: -4px;
}
.about-text {
margin-left: 25px;
margin-right: 25px;
}
.right {
float: left;
}
.gallery {
padding-top: 100px;
width: 100%;
text-align: center;
}
img {
height: 300px;
transition: 0.5s ease;
backface-visibility: hidden;
/* inline-block fügt standardmäßig 4px Padding hinzu
das muss nun wieder subtrahiert werden. */
margin-top: -4px;
}
img:hover {
opacity: 0.5;
}
#img_1 {
border-top-left-radius: 30px;
}
#img_2 {
border-top-right-radius: 30px;
}
#img_3 {
border-bottom-left-radius: 30px;
}
#img_4 {
border-bottom-right-radius: 30px;
}
/* 827 x 178 */
.banner {
width: 410px;
height: 90px;
position: absolute;
right: 0px;
bottom: 0px;
}
The website currently looks like this (with static layout):
Now I want to go away from the fixed layout and want to make the website responsive. However, when I give the fields a relative width the whole layout gets messed up...
This is the css I tried to use to achieve the responsive layout:
html, body {
font-family: "Verdana", Geneva, sans-serif;
color: white;
background-color: black;
height: 100%;
}
hr {
border-top: 1px dotted black;
}
.title {
text-align: center;
padding-bottom: 20px;
}
.wrapper {
border: 1px solid white;
margin: auto;
width: 80%;
}
.left {
float: left;
}
.middle {
width: 40%;
height: auto;
float: left;
border-top: 1px solid white;
border-bottom: 1px solid white;
box-shadow: inset 0px 0px 20px 0px rgba(0,0,0,1);
margin-top: -4px;
}
.about-text {
margin-left: 25px;
margin-right: 25px;
}
.right {
float: left;
}
.gallery {
padding-top: 100px;
width: 100%;
text-align: center;
}
img {
width: 40%;
height: auto;
transition: 0.5s ease;
backface-visibility: hidden;
/* inline-block fügt standardmäßig 4px Padding hinzu
das muss nun wieder subtrahiert werden. */
margin-top: -4px;
}
img:hover {
opacity: 0.5;
}
#img_1 {
border-top-left-radius: 30px;
}
#img_2 {
border-top-right-radius: 30px;
}
#img_3 {
border-bottom-left-radius: 30px;
}
#img_4 {
border-bottom-right-radius: 30px;
}
/* 827 x 178 */
.banner {
width: 20%;
height: 10%;
position: absolute;
right: 0px;
bottom: 0px;
}
It's a matter of WHICH elements get the percentage value. In my adaptation of your fiddle, I assigned width: 30% to .left and right (which are the containers for the images) and made the image width 100% to span the whole width of their containers.
See here: https://jsfiddle.net/35n4dxqn/1/
well, when you give a or a division relative attribute it will be placed relative or according to the previous div i.e. it will not be independent from other divisions.
the solution if you want to make it responsive one forward and efficient way is to use Grid System (Bootstrap class).
What I want to achieve is something like this below
And what I am getting is something where there's too much of a gap between the image and the green border.
how do I make it look like the previous image above.
Here's the link to my codepen - codepen link
Here's the code:
.container {
text-align: center;
width: 80%;
}
.first {
background: rgb(0, 30, 58);
color: white;
}
.span1,
.span2 {
font-size: 36px;
font-weight: bold;
}
.span1 {
color: rgb(72, 174, 137);
}
[type="text"] {
border-radius: 25px;
padding-left: 5px;
}
[type="submit"] {
color: white;
background-color: rgb(72, 174, 137);
border-radius: 25px;
position: relative;
margin-left: -25px;
}
.use {
height: 85%;
margin: 0 auto;
}
.box {
border: 3px solid rgb(72, 174, 137);
width: 55%;
margin: 0 auto;
max-height: 210px;
}
.box .img-responsive {
margin-top: -20px;
}
.para {
text-align: left;
margin-right: 0;
padding-right: 0;
padding-top: 15px;
}
.para strong {
font-weight: 900;
font-size: 16px;
}
.second {
margin-bottom: 30px;
border: 1px solid green;
width: 10%;
}
.threebox {
width: 90%;
margin: 0 auto;
padding-left: 70px;
}
.col-lg-4 {
height: 40%;
}
.col-lg-4 > p {
background-color: white;
border: 2px solid white;
border-top-color: green;
width: 200px;
height: 160px;
box-shadow: 10px 10px 15px;
}
.positions {
margin-top: 60px;
position: relative;
margin-bottom: -50px;
z-index: 2;
}
.positions > h1 {
font-size: 30px;
font-weight: bold;
}
.spanf {
font-size: 18px;
font-weight: bold;
}
.features {
text-align: center;
padding-bottom: 40px;
width: 100%;
margin: 0 auto;
background-color: rgb(242, 243, 245);
height: 1500px;
z-index: 1;
padding-top: 120px;
margin-bottom: 0;
}
.features .row {
border: 2px solid red;
width: 65%;
margin: 0 auto;
}
.features .row p {
text-align: left;
padding-left: 20px;
}
.features button {
border-radius: 20px;
}
.features .row {
margin-top: 40px;
}
.features img {
width: 98%;
height: 98%;
}
.features .row .col-lg-6 {
padding-right: 15px;
padding-left: 2px;
}
.imgright {
position: relative;
border: 3px solid rgb(72, 174, 137);
top: 5%;
width: 40%;
padding-bottom: 0px;
padding-right: 2px;
padding-left: 0;
margin-left: 20px;
margin-top: 20px;
}
.img2 {
position: relative;
top: -25px;
left: -20px;
padding-bottom: 10px;
}
.imgleft {
position: relative;
border: 3px solid rgb(72, 174, 137);
width: 40%;
top: 5%;
margin-left: 10px;
margin-top: 20px;
}
.img3 {
position: relative;
top: -20px;
padding-bottom: 10px;
left: 40px;
}
.pillars {
background-color: rgb(72, 174, 137);
height: 350px;
top: 0;
}
This is the CSS after the changes and rest of your CSS will be there.
.features img {
/* width: 98%; */
/* height: 98%; */
left: 12px;
top: -12px;
box-shadow: -2px 2px 9px;
}
.features .row .col-lg-6 {
/* padding-right: 15px; */
/* padding-left: 2px; */
}
.img2 {
position: relative;
/* padding-bottom: 10px; */
}
.imgleft {
position: relative;
border: 3px solid rgb(72, 174, 137);
width: 40%;
top: 5%;
margin-left: 10px;
margin-top: 20px;
padding: 0;
}
.img3 {
position: relative;
left:30px;
/* top:-20px; */
/* padding-bottom: 10px; */
}
here u already defined .img2 and .img3 classes, your result was effecting by these classes just remove those classes then it works fine, check my snippet
.box .img-responsive {
margin-top: -20px;
} and remove margin-top from here
.container {
text-align: center;
width: 80%;
}
.first {
background: rgb(0, 30, 58);
color: white;
}
.span1,
.span2 {
font-size: 36px;
font-weight: bold;
}
.span1 {
color: rgb(72, 174, 137);
}
[type="text"] {
border-radius: 25px;
padding-left: 5px;
}
[type="submit"] {
color: white;
background-color: rgb(72, 174, 137);
border-radius: 25px;
position: relative;
margin-left: -25px;
}
.use {
height: 85%;
margin: 0 auto;
}
.box {
border: 3px solid rgb(72, 174, 137);
width: 55%;
margin: 0 auto;
max-height: 210px;
}
.box .img-responsive {
margin-top: -20px;
}
.para {
text-align: left;
margin-right: 0;
padding-right: 0;
padding-top: 15px;
}
.para strong {
font-weight: 900;
font-size: 16px;
}
.second {
margin-bottom: 30px;
border: 1px solid green;
width: 10%;
}
.threebox {
width: 90%;
margin: 0 auto;
padding-left: 70px;
}
.col-lg-4 {
height: 40%;
}
.col-lg-4 > p {
background-color: white;
border: 2px solid white;
border-top-color: green;
width: 200px;
height: 160px;
box-shadow: 10px 10px 15px;
}
.positions {
margin-top: 60px;
position: relative;
margin-bottom: -50px;
z-index: 2;
}
.positions > h1 {
font-size: 30px;
font-weight: bold;
}
.spanf {
font-size: 18px;
font-weight: bold;
}
.features {
text-align: center;
padding-bottom: 40px;
width: 100%;
margin: 0 auto;
background-color: rgb(242, 243, 245);
height: 1500px;
z-index: 1;
padding-top: 120px;
margin-bottom: 0;
}
.features .row {
border: 2px solid red;
width: 65%;
margin: 0 auto;
}
.features .row p {
text-align: left;
padding-left: 20px;
}
.features button {
border-radius: 20px;
}
.features .row {
margin-top: 40px;
}
.features img {
width: 98%;
height: 98%;
}
.features .row .col-lg-6 {
padding-right: 15px;
padding-left: 2px;
}
.imgright {
position: relative;
border: 3px solid rgb(72, 174, 137);
top: 5%;
width: 40%;
padding-bottom: 0px;
padding-right: 2px;
padding-left: 0;
margin-left: 20px;
margin-top: 20px;
}
.imgleft {
position: relative;
border: 3px solid rgb(72, 174, 137);
width: 40%;
top: 5%;
margin-left: 10px;
margin-top: 20px;
}
.pillars {
background-color: rgb(72, 174, 137);
height: 350px;
top: 0;
}
<div class="container">
<div class="first">
<p>CONVERSIFIC</p>
<p><span class="span1">The 1st</span><br>Business Intelligence Platform<br><span class="span2">for Shopify</span></p>
<p>We show you how to grow your revenue<br><span class="span3">-all you have to do is take action</span></p>
<form>
<input type="text" placeholder="enter your email" name="email">
<input type="submit" name="submit" value="Add me to Beta">
</form>
<p>Join our beta today,be the first to get access to Conversific</p>
</div><!--first div ends -->
<div class="use">
<h1>Why use Conversicif?</h1>
<hr class="firsth">
<div class="box row">
<div class="col-lg-6 images">
<img class="img-responsive " src="http://res.cloudinary.com/whizzy/image/upload/v1473309440/graph.jpg" alt="graph">
</div>
<div class="col-lg-6 para">
<p><strong>Conversific helps you make intelligent decisions to grow your business</strong><br>
There are plentfy of platforms that make it easy to capture data and analytics about your ecommerce site.But when it comes to understanding the data you've captured, it's not always clear what's important and where to make changes.</p>
</div>
</div><!--box div ends -->
<div class="positions">
<h1>How does Conversific work?</h1>
<p>Say goodbye to gathering reports and analyzing data and head straight to decision making </p>
<hr class="second">
<div class="threebox row">
<div class="col-lg-4"><p>Conversific is installed onto your ecommerce store with just one click from your shopify store</p></div>
<div class="col-lg-4"><p>After the installation you just need to install google analytics</p></div>
<div class="col-lg-4"><p>Immediately after you have signed in you see a comprehensive reports overview</p></div>
</div><!--threebox row ends -->
</div><!-- positions div ends-->
</div><!--use div ends -->
<div class="features">
<h1> Features you'll love</h1>
<p>These are the features you are going to love no matter what<br>
So, is this the end of the paragraph or what or are you gonna keep<br>
typing till your fingers bleed??</p>
<div class="row">
<div class="col-lg-6">
<p>ECOMMERCE FOCUS<br><span class="spanf">Decision Focused Dashboards To Supercharge Your Ecommerce Business</span><br>
There are plenty of platforms that make it easy to capture data and analytics about your ecommerce site. But when it comes to understanding the data you've captured. It's not always clear what's important and where to make changes.<br>
<button>Join Now</button></p>
</div>
<div class="col-lg-6 imgright">
<img class="img-responsive img2 " src="http://res.cloudinary.com/whizzy/image/upload/v1473309440/graph.jpg" alt="graph">
</div>
</div><!-- row ends -->
<div class="row">
<div class="col-lg-6 imgleft">
<img class="img-responsive img3" src="http://res.cloudinary.com/whizzy/image/upload/v1473309440/graph.jpg" alt="graph">
</div>
<div class="col-lg-6"><p>EASY TO UNDERSTAND<br><span class="spanf">Optimize Your Product & Category<br> Performance</span><br>
There are plenty of platforms that make it easy to capture data and analytics about your ecommerce site. But when it comes to understanding the data you've captured. It's not always clear what's important and where to make changes.<br>
<button>Join Now</button></p></div>
</div><!-- row ends -->
<div class="row">
<div class="col-lg-6"><p>INCREASE REVENUE<br><span class="spanf">Turbo Boost Your marketing and Find<br> Top Performing Marketing Channels</span><br>
See which marketing channels are the most effective for your business<br>and maximize your return on investment<br>
<button>Join Now</button></p></div>
<div class="col-lg-6 imgright">
<img class="img-responsive img2" src="http://res.cloudinary.com/whizzy/image/upload/v1473309440/graph.jpg" alt="graph">
</div>
</div><!-- row ends -->
<div class="row">
<div class="col-lg-6 imgleft">
<img class="img-responsive img3" src="http://res.cloudinary.com/whizzy/image/upload/v1473309440/graph.jpg" alt="graph">
</div>
<div class="col-lg-6"><p>ECOMMERCE FOCUS<br><span class="spanf">Decision Focused Dashboards To<br> Supercharge Your Ecommerce Business</span><br>
There are plenty of platforms that make it easy to capture data and analytics about your ecommerce site. But when it comes to understanding the data you've captured. It's not always clear what's important and where to make changes.<br>
<button>Join Now</button></p></div>
</div><!-- row ends -->
</div><!-- features div ends -->
<div class="pillars">
<h1>The 4 pillars of Conversific</h1>
<p>Stop wasting time on your decision making process, increase revenue and reduce costs </p>
<hr>
</div><!-- pillars div ends -->
<div class="team"></div>
<div class="end"></div>
</div><!-- container div ends -->