I've set up a system of side by side scrolling divs (code below). However, whenever there is a different amount of content in them, they appear on different levels (as seen in the below picture). I'm not quite sure what's going on and I have a feeling it has something to do with the CSS display attribute. Code is included. This project is using Bootstrap. The brackets in my code are from my CMS. It's automatically embedding content.
Here's a representative JSFiddle: https://jsfiddle.net/d8jopwnr/
My HTML code:
<div class="row">
<div class="col-lg-10 col-lg-offset">
{exp:channel:entries channel="Constructs" limit="1"}
<h1>{title} <span class="header-box">{abbreviation}</span></h1>
<br>
<br>
<div class="container level-box">
<div class="row">
{if summary!=""}
<div class="level col-md-4">
<h4>Summary</h4>
{summary}
Download ToAM° Construct Map
</div>
{/if} {if level_1!=""}
<div class="level col-md-4 col-md-offset-1 shift-margin-level">
<h4>{title} Level 1: {level_1_title}</h4>
{level_1}
Download ToAM° Construct Map
</div>
{/if} {if level_2!=""}
<div class="level col-md-4 col-md-offset-1 shift-margin-level">
<h4>{title} Level 2: {level_2_title}</h4>
{level_2}
Download ToAM° Construct Map
</div>
{/if}
<div class="level col-md-4 col-md-offset-1 shift-margin-level">
<h4>{title} Level 3: {level_3_title}</h4>
{if level_3!=""}{level_3}{/if}
Download ToAM° Construct Map
</div>
{if level_4!=""}
<div class="level col-md-4 col-md-offset-1 shift-margin-level">
<h4>{title} Level 4: {level_4_title}</h4>
{level_4}
Download ToAM° Construct Map
</div>
{/if} {if level_5!=""}
<div class="level col-md-4 col-md-offset-1 shift-margin-level">
<h4>{title} Level 5: {level_5_title}</h4>
{level_5}
Download ToAM° Construct Map
</div>
{/if} {/exp:channel:entries}
</div>
</div>
</div>
</div>
</div>
My Sass code (in my opinion, it's easier to understand than regular CSS. If you disagree, you can translate it to CSS here):
$header-box-vertical-padding: 3px;
$header-box-horizontal-padding: 6px;
$box-height: 60%;
.header-box {
background-color: #0000FF;
color: white;
padding-top: $header-box-vertical-padding;
padding-bottom: $header-box-vertical-padding;
padding-right: $header-box-horizontal-padding;
padding-left: $header-box-horizontal-padding;
border-radius: 6px;
}
.level-box > .row {
overflow-x: auto;
white-space: nowrap;
}
.level-box > .row > .col-md-4 {
display: inline-block;
float: none;
}
.level{
height: 60%;
border-radius: 16px;
width: 200px;
overflow-x: initial;
white-space: normal;
background-color: #0000FF;
color: white;
display: inline-block;
}
.shift-margin-level{ // used to adjust the spacing between levels on constucts
margin-left: 5% !important;
}
.map-display{
width:100%;
border: lightblue solid 1px;
border-radius: 4px;
padding: 8px;
margin-top: 10px;
}
.size{
font-size: 36px;
}
.vertical-center{
display:inline-block;
vertical-align:middle;
}
// scrollbar stuff
.level-box::-webkit-scrollbar-track
{
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
background-color: #F5F5F5;
}
.level-box::-webkit-scrollbar
{
width: 6px;
background-color: #F5F5F5;
}
.level-box::-webkit-scrollbar-thumb
{
background-color: #000000;
}
If you add a small line of code to the .col-md-4 to set the vertical-align: top then the first box will align to the top of the container with the rest.
.level-box > .row > .col-md-4 {
vertical-align: top;
display: inline-block;
float: none; }
Related
so I'm a beginner and I started this project by first writing CSS in styles.scss and then transforming the code inside of it using scss tools. I made an each loop to loop through a set of colors in my color map, placed in a mixin and put that mixin under [class^=btn].
I don't know why this doesn't work?
Here is my SCSS:
//colors
$base-grey: #808080;
$base-white: #ffffff;
$base-green: #71eeb8;
$base-blue: #2dcae6; //base-success: #33c052;
$base-red: #ff6666; //red
$base-orange: #ff751a; //warning
$base-purple: #8a54f7; //info
// grid base class
.grid {
// .grid__row
&__row {
padding: 1em 10px;
display: flex;
flex-direction: column;
// NOTE: replace with media query mixin if aiming for exceeds
#media (min-width: 768px) {
flex-direction: row;
}
}
// .grid__col
&__col {
// create grid columns dynamically
// loop through each column size
#for $i from 1 through 12 {
// concatenate CSS selector, ie when $i = 1,
// selector would be .grid__col--1
&--#{$i} {
// base styles applied to all grid columns
// NOTE: could be converted to a placeholder, along with margin
// from the media query
margin-top: 10px;
flex-basis: 100%;
border: 1px red solid;
// NOTE: replace with media query mixin if aiming for exceeds
#media (min-width: 768px) {
// base stlyes applied to all grid columns
margin-top: 0;
// make column width a percentage of the column number / total columns
flex-basis: #{$i / 12 * 100 + "%"} ;
}
}
}
}
}
// targets all elements with classes that begin with grid__col
[class^=grid__col] {
// grid__col + grid__col, targets two sibling columns
& + & {
// NOTE: replace with media query mixin if aiming for exceeds
#media (min-width: 768px) {
// add grid gutter
margin-left: 10px;
}
}
}
.grid {
&__row {
display: flex;
}
}
//BASE
.container {
text-align: left;
font-family: 'Arial Narrow', Arial,sans-serif;
color: $base-grey;
padding: 5px;
font-weight: 500;
}
p {
text-align: left;
line-height: 1.3;
}
a {
text-decoration: none;
}
//NAVIGATION
.nav {
list-style-type: none;
padding: 0;
text-align: center;
}
.nav__item a {
display: block;
color: inherit;
margin: 8px 0;
padding: 8px;
}
.nav__item a:hover {
color: $base-white;
background-color: $base-green;
}
//TYPOGRAPHY
//link
.link {
color: $base-blue;
font-weight: bold;
}
//blockquote
.blockquote {
border-left: $base-green 8px solid;
padding-left: 10px;
font-style: oblique;
font-size: 1.2em;
}
// headlines
#mixin h2-font-weight {
font-weight: 100;
}
.headline--primary {
color: $base-green;
margin-left: 10px;
}
.headline--secondary {
text-align: left;
#include h2-font-weight;
}
//FORM
.form {
display: flex;
flex-direction: column;
&__input {
border: none;
border-bottom: 2px solid $base-green;
margin-bottom: 15px;
}
&__label--hidden {
display: none;
}
& .headline--secondary {
#include h2-font-weight;
}
}
//BUTTONS
#mixin button-styles {
display: block;
width: 100%;
border: none;
margin-bottom: 15px;
padding: 10px;
color: $base-white;
text-transform: uppercase;
font-weight: bold;
}
$button-colors :(
default:$base-blue,
success:$base-green,
error:$base-red,
warning:$base-orange,
info:$base-purple
);
#mixin button-colors {
#each $button, $color in $button-colors {
.btn--#{$button} {
background-color: #{$color};
}
}
}
[class*=btn] {
#include button-styles;
}
//IMAGE
#mixin center-images {
display: block;
max-width: 100%;
margin: 0 auto;
padding: 8px;
}
[class^=img] {
#include center-images;
}
.img {
&--frame {
border: 2px solid $base-grey;
}
}
This is my HTML:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Circles UI Kit</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/normalize.css">
</head>
<!--
List of classes used
Grid:
.container
.grid__row
.grid__col--1 *NOT USED HERE
.grid__col--2 *
.grid__col--3
.grid__col--4
.grid__col--5
.grid__col--6
.grid__col--7
.grid__col--8
.grid__col--9
.grid__col--10 *
.grid__col--11 *
.grid__col--12
.card
.centered
.theme__colors
(.grid__col--1, .grid__col--2, .grid__col--10, and .grid__col--11 are not used here in the HTML but would be good to include in the Sass)
Typography:
.container
.link
.blockquote
.headline--primary
.headline--secondary
Image:
.img--logo
.img--frame
.img--avatar
Navigation:
.nav
.nav__item
Buttons:
.btn--default
.btn--success
.btn--error
.btn--warning
.btn--info
.theme__colors
Forms:
.form
.form__label--hidden
.form__input
-->
<body class="container">
<div class="grid__row">
<div class="grid__col--3">
<a class="link" href="/">
<img class="img--logo" alt="circles logo" src="images/logo.png">
</a>
</div>
<div class="grid__col--9">
<nav role="navigation">
<ul class="nav">
<li class="nav__item">Typography</li>
<li class="nav__item">Buttons</li>
<li class="nav__item">Form</li>
<li class="nav__item">Images</li>
<li class="nav__item">Grid</li>
</ul>
</nav>
</div>
</div>
<div class="grid__row">
<div class="grid__col--12">
<div class="card">
<p>This is what the navigation menu looks like when the screen is at 769px or higher. When the screen is less
than 769px,
the menu will be displayed vertically.</p>
</div>
</div>
</div>
<div class="grid__row">
<div class="grid__col--8">
<div class="card">
<h4 id="type" class="headline--secondary">Typography</h4>
<h1 class="headline--primary">Take a look at this amazing headline</h1>
<p>This is a typical paragraph for the UI Kit. Here is what a link might look like.
The
typical font family for this kit is Helvetica Neue. This kit is intended for clean and refreshing web layouts.
No jazz hands here, just the essentials to make dreams come true, with minimal clean web design. The kit comes
fully equipped with everything from full responsive media styling to buttons to form fields. <em>I enjoy using
italics as well from time to time</em>.
Fell free to create the most amazing designs ever with this kit. I truly hope you enjoy not only the kit but
this
amazing paragraph as well. :)</p>
<blockquote class="blockquote">You know what really gets me going? A really nice set of block quotes. That's
right, block quotes that say, "Hey,
I'm an article you want to read and nurture."</blockquote>
</div>
</div>
<div class="grid__col--4">
<form class="form">
<legend id="forms" class="headline--secondary">Form Elements</legend>
<img class="img--avatar" src="images/avatar.png" alt="Avatar">
<label class="form__label--hidden" for="username">Username:</label>
<input class="form__input" type="text" id="username" placeholder="Username">
<label class="form__label--hidden" for="password">Password:</label>
<input class="form__input" type="password" id="password" placeholder="Password">
<button class="btn--default theme__colors" type="submit" value="Login">Login</button>
</form>
</div>
</div>
<h4 id="images" class="headline--secondary">Images</h4>
<div class="grid__row">
<div class="grid__col--6">
<img class="img--frame" src="images/image.png" alt="sample image">
</div>
<div class="grid__col--6">
<img class="img--avatar" src="images/avatar.png" alt="Avatar">
</div>
</div>
<h4 id="buttons" class="headline--secondary">Buttons</h4>
<div class="grid__row">
<div class="grid__col--12">
<button class="btn--default theme__colors">default</button>
<button class="btn--success theme__colors">success</button>
<button class="btn--error theme__colors">error</button>
<button class="btn--warning theme__colors">warning</button>
<button class="btn--info theme__colors">info</button>
</div>
</div>
<h4 id="grid" class="headline--secondary">Grid System</h4>
<div class="grid__row">
<div class="grid__col--12 theme__colors">.grid__col--12</div>
</div>
<div class="grid__row">
<div class="grid__col--6 theme__colors">.grid__col--6</div>
<div class="grid__col--6 theme__colors">.grid__col--6</div>
</div>
<div class="grid__row">
<div class="grid__col--4 theme__colors">.grid__col--4</div>
<div class="grid__col--4 theme__colors">.grid__col--4</div>
<div class="grid__col--4 theme__colors">.grid__col--4</div>
</div>
<div class="grid__row">
<div class="grid__col--3 theme__colors">.grid__col--3</div>
<div class="grid__col--3 theme__colors">.grid__col--3</div>
<div class="grid__col--3 theme__colors">.grid__col--3</div>
<div class="grid__col--3 theme__colors">.grid__col--3</div>
</div>
<div class="grid__row">
<div class="grid__col--5 theme__colors">.grid__col--5</div>
<div class="grid__col--7 theme__colors">.grid__col--7</div>
</div>
<div class="grid__row">
<div class="grid__col--8 theme__colors">.grid__col--8</div>
<div class="grid__col--4 theme__colors">.grid__col--4</div>
</div>
<div class="grid__row">
<div class="grid__col--7 theme__colors centered">.centered .grid__col--7</div>
</div>
</body>
</html>
You are missing two things:
The mixin of button colours need to be:
#mixin button-colors {
#each $button, $color in $button-colors {
&.btn--#{$button} {
background-color: #{$color};
}
}
}
with & before .btn.
You didn't call your mixin. You need to write:
[class*=btn] {
#include button-styles();
#include button-colors();
}
I have a JavaScript script that basically hides a box upon clicking the top two boxes. Upon clicking one of the boxes on top, one of the boxes on the bottom hides. How do I make the two boxes on the bottom stay centered?
Here is the landing page:
I want the divs on the bottom centered, once a box is hidden. I want the SharePoint and Teams boxes centered after the other box is hidden.
Center the bottom two div's after change ^
Code:
.margin-bottom-20 {
margin-bottom: 20px;
}
.collabProjects:hover, .collabFiles:hover, .collabSocially:hover {
box-shadow: 0 0 15px rgba(33,3,3,.2);
}
.decisionTreeBox {
background-color: #4B92DB;
color: white;
width: 300px;
height: 140px;
display: flex;
justify-content: center;
align-items: center;
transition: box-shadow .3s;
}
#decisionTreeOneDrive {
background-color: #094AB2;
color: white;
width: 300px;
height: 140px;
display: flex;
justify-content: center;
align-items: center;
}
#decisionTreeSharePoint {
background-color: #008CE7;
color: white;
width: 300px;
height: 140px;
display: flex;
justify-content: center;
align-items: center;
}
#decisionTreeTeams {
background-color: #4A1EBD;
color: white;
width: 300px;
height: 140px;
display: flex;
justify-content: center;
align-items: center;
}
#innerBoxHeadings {
color: white!important;
text-align: center;
padding-top: 5px;
}
#columnMiddleBorderLeft, #pageTitle {
display:none!important;
}
<div class="outer-container">
<div class="row">
<div class="col-md-6" style="text-align: center;">
<div data-collaborate="shareCollab" class="decisionTreeBox" style="font-size: x-large; float: right;">
Share and Collaborate</div>
</div>
<div class="col-md-6" style="text-align: center;">
<div data-collaborate="shareExternally" class="decisionTreeBox" style="font-size: x-large;">
Share Externally</div>
</div>
</div>
<hr />
<div class="container" style="padding: 0px;">
<div class="row">
<a href="/TrainingResourceCenter/O365Training/Pages/OneDrive.aspx">
<div class="col-md-4 margin-bottom-20" style="text-align: center;">
<div data-decision="shareExternally" id="decisionTreeOneDrive">
<h3 id="innerBoxHeadings"><img src="/TrainingResourceCenter/O365Training/PublishingImages/onedrive-logo.png" style="width: 65px; height: 65px; padding-bottom: 5px; padding-right: 10px; vertical-align: middle;" />OneDrive</h3>
</div>
</div>
</a>
<a href="/TrainingResourceCenter/O365Training/Pages/SharePointOnline.aspx">
<div class="col-md-4 margin-bottom-20" style="text-align: center;">
<div data-decision="shareCollab shareExternally" id="decisionTreeSharePoint">
<h3 id="innerBoxHeadings"><img src="/TrainingResourceCenter/O365Training/PublishingImages/SharePointDecisionTree.png" style="padding-bottom: 5px; padding-right: 10px; vertical-align: middle;" />SharePoint</h3>
</div>
</div>
</a>
<a href="/TrainingResourceCenter/O365Training/Pages/Teams.aspx">
<div class="col-md-4 margin-bottom-20" style="text-align: center;">
<div data-decision="shareCollab" id="decisionTreeTeams">
<h3 id="innerBoxHeadings"><img src="/TrainingResourceCenter/O365Training/PublishingImages/TeamsDecisionTree.png" style="padding-bottom: 5px; padding-right: 10px; vertical-align: middle;" />Teams</h3>
</div>
</div>
</a>
</div>
</div>
</div>
<script>
function projectCollab() {
var divsToCange = document.querySelectorAll('[data-decision]'),
attr = this.getAttribute('data-collaborate');
for (var i = 0; i < divsToCange.length; i++) {
var d = divsToCange[i];
if (d.getAttribute('data-decision').includes(attr)) { /* Had: == attr) { */
d.parentNode.style.display = 'block';
} else {
d.parentNode.style.display = 'none';
}
}
return false;
}
var divButtons = document.querySelectorAll('[data-collaborate]');
for (var i = 0; i < divButtons.length; i++) {
divButtons[i].addEventListener('click', projectCollab);
}
</script>
There's an old technique of centering the content of the parent, then making the children display: inline-block;. You will have to account for the visibility of the white-space " " character — but that is pretty well documented (e.g. Remove Whitespace Between Inline-Block Elements). You'll have to play with margin to restore your spacing, AND remember to change the JS to reflect inline-block instead of block when restoring the elements.
In the interest of selector sanity, I added an example class to the containing row element in the code demo.
HTML
<div class="row centered-buttons">
CSS
.centered-buttons {
text-align: center;
}
.centered-buttons a {
display: inline-block;
vertical-align: middle;
}
.margin-bottom-20 {
margin-bottom: 20px;
}
.collabProjects:hover,
.collabFiles:hover,
.collabSocially:hover {
box-shadow: 0 0 15px rgba(33, 3, 3, .2);
}
.decisionTreeBox {
background-color: #4B92DB;
color: white;
width: 300px;
height: 140px;
display: flex;
justify-content: center;
align-items: center;
transition: box-shadow .3s;
}
#decisionTreeOneDrive {
background-color: #094AB2;
color: white;
width: 300px;
height: 140px;
display: flex;
justify-content: center;
align-items: center;
}
#decisionTreeSharePoint {
background-color: #008CE7;
color: white;
width: 300px;
height: 140px;
display: flex;
justify-content: center;
align-items: center;
}
#decisionTreeTeams {
background-color: #4A1EBD;
color: white;
width: 300px;
height: 140px;
display: flex;
justify-content: center;
align-items: center;
}
#innerBoxHeadings {
color: white!important;
text-align: center;
padding-top: 5px;
}
#columnMiddleBorderLeft,
#pageTitle {
display: none!important;
}
.centered-buttons {
text-align: center;
}
.centered-buttons a {
display: inline-block;
vertical-align: middle;
}
<div class="outer-container">
<div class="row">
<div class="col-md-6" style="text-align: center;">
<div data-collaborate="shareCollab" class="decisionTreeBox" style="font-size: x-large; float: right;">
Share and Collaborate</div>
</div>
<div class="col-md-6" style="text-align: center;">
<div data-collaborate="shareExternally" class="decisionTreeBox" style="font-size: x-large;">
Share Externally</div>
</div>
</div>
<hr />
<div class="container" style="padding: 0px;">
<div class="row centered-buttons">
<a href="/TrainingResourceCenter/O365Training/Pages/OneDrive.aspx">
<div class="col-md-4 margin-bottom-20" style="text-align: center;">
<div data-decision="shareExternally" id="decisionTreeOneDrive">
<h3 id="innerBoxHeadings"><img src="/TrainingResourceCenter/O365Training/PublishingImages/onedrive-logo.png" style="width: 65px; height: 65px; padding-bottom: 5px; padding-right: 10px; vertical-align: middle;" />OneDrive</h3>
</div>
</div>
</a>
<a href="/TrainingResourceCenter/O365Training/Pages/SharePointOnline.aspx">
<div class="col-md-4 margin-bottom-20" style="text-align: center;">
<div data-decision="shareCollab shareExternally" id="decisionTreeSharePoint">
<h3 id="innerBoxHeadings"><img src="/TrainingResourceCenter/O365Training/PublishingImages/SharePointDecisionTree.png" style="padding-bottom: 5px; padding-right: 10px; vertical-align: middle;" />SharePoint</h3>
</div>
</div>
</a>
<a href="/TrainingResourceCenter/O365Training/Pages/Teams.aspx">
<div class="col-md-4 margin-bottom-20" style="text-align: center;">
<div data-decision="shareCollab" id="decisionTreeTeams">
<h3 id="innerBoxHeadings"><img src="/TrainingResourceCenter/O365Training/PublishingImages/TeamsDecisionTree.png" style="padding-bottom: 5px; padding-right: 10px; vertical-align: middle;" />Teams</h3>
</div>
</div>
</a>
</div>
</div>
</div>
<script>
function projectCollab() {
var divsToCange = document.querySelectorAll('[data-decision]'),
attr = this.getAttribute('data-collaborate');
for (var i = 0; i < divsToCange.length; i++) {
var d = divsToCange[i];
if (d.getAttribute('data-decision').includes(attr)) { /* Had: == attr) { */
d.parentNode.style.display = 'block';
} else {
d.parentNode.style.display = 'none';
}
}
return false;
}
var divButtons = document.querySelectorAll('[data-collaborate]');
for (var i = 0; i < divButtons.length; i++) {
divButtons[i].addEventListener('click', projectCollab);
}
</script>
In cases like this, I usually conditionally set the class of the content that changes depending on how many items are present. For example, imagine you're checking an array called items that is either 2 or 3 items long. Here is some pseudocode that shows you what I'm thinking.
let itemsClass;
if (items.length === 2) {
itemsClass = 'col-md-6';
} else {
itemsClass = 'col-md-4';
}
myElement.setClass(itemsClass);
You could set a click handler that would check after you click a button or whatever. In react, that could be part of your component render() method.
I don't know what you're using for JS so I won't try to write your code for you. But the gist of it is, decide the class name on the fly with JS and apply it to your elements.
edit: Sorry, I didn't read your entire code snippet. This is something you could add to the handler you already have. You'd just have to grab the elements and alter the classes at that time.
Add the following CSS to the row class:
<div class="container" style="padding: 0px;">
<div class="row" style="justify-content: center">
Since bootstrap uses flexbox system, this should work for you.
What you are asking for is built into BS. But you've muddied the framework by adding html where it ought not be. specifically wrapping BS cols with an anchor tag which breaks the BS grid system, specifically the rule that states only cols can be children of rows.
I've made your html substantially shorter for simplicity and altered your js somewhat to showcase the hiding part. I hope this a decent example that you can expand upon.
FIXES:
I've moved the anchor tab inside the col. This was breaking the alignment of the BS Grid And is also incorrect markup per the BS grid system.
I altered your JS to hide the col, not the anchor. This allows the BS flex grid to properly do it's alignment
In the javascript, consider adding a attribute to your markup such that you don't have to navigate the right number of parent levels. As it stands, if you add more layers to the col html, your JS will break.
function projectCollab() {
var divsToChange = document.querySelectorAll('[data-decision]'),
attr = this.getAttribute('data-collaborate');
for (var i = 0; i < divsToChange.length; i++) {
var d = divsToChange[i];
d.parentNode.parentNode.hidden = ! d.getAttribute('data-decision').includes(attr);
}
return false;
}
var divButtons = document.querySelectorAll('[data-collaborate]');
for (var i = 0; i < divButtons.length; i++) {
divButtons[i].addEventListener('click', projectCollab);
}
.collabProjects:hover,
.collabFiles:hover,
.collabSocially:hover {
box-shadow: 0 0 15px rgba(33, 3, 3, .2);
}
div[data-decision],
div[data-collaborate]{
color: white;
width: 200px;
height: 100px;
}
.decisionTreeBox {
background-color: #4B92DB;
}
#decisionTreeOneDrive {
background-color: #094AB2;
}
#decisionTreeSharePoint {
background-color: #008CE7;
}
#decisionTreeTeams {
background-color: #4A1EBD;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<div class="outer-container">
<div class="container-fluid">
<div class="row justify-content-center">
<div class="col-4">
<div data-collaborate="shareCollab" class="decisionTreeBox">
Share and Collaborate</div>
</div>
<div class="col-4">
<div data-collaborate="shareExternally" class="decisionTreeBox">
Share Externally</div>
</div>
</div>
<hr />
<div class="row justify-content-center">
<div class="col-4">
<a href="#">
<div data-decision="shareExternally" id="decisionTreeOneDrive">
<h3 id="innerBoxHeadings">OneDrive</h3>
</div>
</a>
</div>
<div class="col-4">
<a href="#">
<div data-decision="shareCollab shareExternally" id="decisionTreeSharePoint">
<h3 id="innerBoxHeadings">SharePoint</h3>
</div>
</a>
</div>
<div class="col-4">
<a href="#">
<div data-decision="shareCollab" id="decisionTreeTeams">
<h3 id="innerBoxHeadings">Teams</h3>
</div>
</a>
</div>
</div>
</div>
</div>
This is my HTML:
<div class="row trolibelanja">
<div class="col-md-3">
<img src="http://2.bp.blogspot.com/-WGiyrP7xGOk/VQlHwjgporI/AAAAAAAABHI/zLGXTH0-H2w/s1600/Mie%2BAyam%2B(4).jpg" class="detailfoto">
</div>
<div class="col-md-4">
<p class="detailnama">Mie Ayam Bakso</p>
<p class="detailtoko">Toko Bu Lastri</p>
</div>
<div class="col-md-2">
<p class="detailharga">Rp. 30.000</p>
</div>
<div class="col-md-2">
<div class="input-group">
<span class="input-group-btn">
<button class="btnjumlah" type="button">-</button>
</span>
<input type="text" class="form-control jumlah" value="1">
<span class="input-group-btn">
<button class="btnjumlah" type="button">+</button>
</span>
</div>
</div>
<div class="col-md-1">
</div>
</div>
This is my css:
body{
background-color: #661f61 !important;
font-family: 'Saira Extra Condensed', sans-serif !important;
}
.container-fluid.keranjang {
background-color: #e9e9e9;
flex: 1;
}
.container.keranjang {
}
.row.trolibelanja {
background-color: #e1e1e1;
position: relative;
padding-top: 10px;
padding-bottom: 23px;
}
.row.trolibelanja:after{
background-image: -webkit-linear-gradient(135deg, #6e1c64 25%, #e27f31 25%) !important;
position: absolute;
content: " ";
width: 100%;
height: 15px;
bottom: 0;
}
.detailfoto {
width: 100%;
height: 110px;
border: 6px solid white;
}
.detailnama{
font-size: 20px;
font-weight: bold;
}
.detailtoko{
line-height: 20px;
margin: -17px 0px;
}
.detailharga{
font-size: 20px;
font-weight: bold;
text-align: center;
}
.input-group .jumlah {
width: 50%;
text-align: center;
}
.input-group .btnjumlah {
background-color: #e27f31;
color: white;
border: 0;
font-size: 20px;
font-weight: bold;
padding: 0px 10px;
height: 100%;
}
I am trying to put text and form next to photo using bootstrap, as in photo below:
enter image description here
My code result:
enter image description here
Please let me know what am I missing? I tried each combination of display that i know, but they wouldn't work. Thank you
Arrange your columns properly. And you will be good. put image in one column (col-md-3 in this case) and rest of the content in another (col-md-9), then put all rest of the content in a new row. I would suggest that you have a better understanding of the rows and columns from bootstrap website.
https://www.w3schools.com/bootstrap/bootstrap_grid_system.asp
<div class="row trolibelanja">
<div class="col-md-3">
<img src="http://2.bp.blogspot.com/-WGiyrP7xGOk/VQlHwjgporI/AAAAAAAABHI/zLGXTH0-H2w/s1600/Mie%2BAyam%2B(4).jpg" class="detailfoto">
</div>
<div class="col-md-9">
<div class="row">
<div class="col-md-4">
<p class="detailnama">Mie Ayam Bakso</p>
<p class="detailtoko">Toko Bu Lastri</p>
</div>
<div class="col-md-2">
<p class="detailharga">Rp. 30.000</p>
</div>
<div class="col-md-2">
<div class="input-group">
<span class="input-group-btn">
<button class="btnjumlah" type="button">-</button>
</span>
<input type="text" class="form-control jumlah" value="1">
<span class="input-group-btn">
<button class="btnjumlah" type="button">+</button>
</span>
</div>
</div>
</div>
</div>
</div>
Add flex-wrap: nowrap; to your .row.trolibelanja like this:
.row.trolibelanja {
background-color: #e1e1e1;
position: relative;
padding-top: 10px;
padding-bottom: 23px;
flex-wrap: nowrap;
}
I made codepen example with your code: https://codepen.io/anon/pen/wPZoXX
i ran your code on bootsnipp and found everything is placed side by side to each other, except for the fact that you did not add img-responsive to the image class. and that the below code is distorting your design.
.row.trolibelanja:after{
background-image: -webkit-linear-gradient(135deg, #6e1c64 25%, #e27f31 25%) !important;
position: absolute;
content: " ";
width: 100%;
height: 15px;
bottom: 0;
}
dont you what you intent designing with that, but i think you need to run a check that css code .
when i added your css to it, it distort the whole code.
first review your CSS is well written , targeting the right class.
second add img-responsive to the img class and i think you are good
to go.
I have a problem with the y-scrollbar.
My problem is that when i hover the DIV, a y-scrollbar is shown afterward, which this will makes everything in that DIV shrink a bit. How can i avoid this?
html
<div class="ht ov-h darker-bg p-r-3">
<h1 class="widget-title p-y-2 p-x-1"> Top Artists </h1>
<ul class="list-artists p-l-0">
{{#each artists as |artist|}}
<li>
<a href="#" class="link-nostyle">
<div class="row p-y-1">
<div class="col-xs-4">
<img src="{{artist.image}}" class="img-fluid img-circle">
</div>
<div class="col-off-xs-1 col-xs-7 vertical-text">
<span> {{artist.name}} </span>
</div>
</div>
</a>
</li>
{{/each}}
</ul>
</div>
css
.widget-title {
font-size: 1rem;
font-weight: bold;
text-transform: uppercase;
margin-bottom: $spacer-y;
}
.widget {
background: #E0EAEC;
}
.ov {
overflow: auto;
}
.ov-h {
overflow: hidden;
&:hover, &:focus {
overflow: auto;
}
}
.ht {
height: 100%;
}
You have a bit of options here.
1- You can set the scrollbar to be always visible, using overflow-y:scroll
2- You can use jQuery scrollbars, like 'Perfect scrollbar'
3- You can always hide the overflow while hovering, using overflow-y:hidden in your &:hover, &:focus.
Technologies:
Bootstrap 3
Less
Jade
Angular
Issue:
I'm using .col-xs-12.col-md-6 for the section.
For some reason when it should switch from .col-md-6 and .col-xs-12 should be applied so that the column can stretch the full width of the screen, the layout doesn't spread out until 743 screen width. (It should go full width at 991px or if i'm wrong atleast 767px screen width).
I have custom styling on .col-md-6 and apply 49% to the width of that class bc .col-md-5 was too small and .col-md-6 was too large to add the needed 20px margin space in between. (styling guidelines).
I removed the width: 49%; when seeing what would happen at the 992 and 768 break point and there is nothing.
It just breaks at random breakpoints.
(I've tested where it breaks for col-lg-6 and col-xl-6 or 5 .. just to test it out and it continues to break in break point areas not connected to the usual 768, 992, 1200 etc.)
I have removed styling from every place possible to see if thats effecting it ..
This is an include file and so even styling connected to the main page. (I put it back bc that wasn't the cause).
These break point additions have worked in the past I don't know whats wrong now.
My only other alternative is using media queries instead which I will try in the meantime but I am wanting to avoid that.
Update:
I reformatted the code in an entirely separate file from the project and put it in regular html and it worked fine. I copied and pasted the code at the very bottom. I removed angular and left it hard coded so that i can open in the browser quickly. I am thinking it may have something to do with the surrounding files in this project. I copied and pasted the code at the very bottom.
Jade file:
#pizza
.col-xs-12
h3 Other Shops
.col-xs-12.col-md-6(ng-repeat="other in otherShops")
.col-xs-12(ng-repeat="tag in other.tags | limitTo: 1")
img(ng-src="{{tag.sm_active_url}}")
{{tag.name}}
.col-xs-3
img(src="http://www.carlotfinance.com/assets/img/car_placeholder.jpg", alt="placeholder image")
.col-xs-8
h2
a(href="#/shops/{{shop.id}}/detail") {{ other.name }}
.glyphicon.glyphicon-road
.glyphicon.glyphicon-unchecked
p {{ other.address }}
p {{ other.phone }}
button.btn.col-xs-12.makeAppointmentBtn(type='button', ng-controller='makeAppointmentCtrl', ng-click='open()') Make Appointment
Less:
#pizza{
h3{
color: #999;
}
.col-md-6{
background-color: #ffffff;
border-radius: 8px;
margin-bottom: 50px;
padding-left: 0;
padding-right: 0;
// width: 49%;
min-height: 440px;
&:nth-child(even){
margin-right: 20px;
}
h2{
a{
color: #000;
}
a:hover{
text-decoration: none;
}
}
.col-xs-3{
margin-left: 20px;
margin-top: 30px;
img{
width: 100%;
}
}
.btn{
position: absolute;
background-color: #003366;
padding: 10px;
border-radius: 8px;
color: #fff;
bottom: 0;
left: 0;
}
.glyphicon{
color: #999;
font-size: 24px;
}
.col-xs-12{
font-size: 24px;
margin-top: 20px;
img{
margin-left: 20px;
}
}
.col-xs-8{
margin-bottom: 40px;
}
}
}
Reformatted code:
<!DOCTYPE html>
<html class="full" lang="en">
<head>
<title>Pizza</title>
<!-- Bootstrap Core CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="col-xs-12 col-md-6 ng-scope">
<div class="col-xs-12">
<img ng-src="https://garageapi.herokuapp.com/tag_tab_icons/Tools/icon-tool-darkblue-25.png" src="https://garageapi.herokuapp.com/tag_tab_icons/Tools/icon-tool-darkblue-25.png"> Tools</div><!-- end ngRepeat: tag in other.tags | limitTo: 1 -->
<div class="col-xs-3"><img src="http://www.carlotfinance.com/assets/img/car_placeholder.jpg" alt="placeholder image"></div>
<div class="col-xs-8">
<h2>Pizza Place
<div class="glyphicon glyphicon-road"></div>
<div class="glyphicon glyphicon-unchecked"></div>
</h2>
<p>1234 M Ave, Austin, TX 27000</p>
<p>(555) 400 2800</p>
</div>
<button type="button" class="btn col-xs-12 makeAppointmentBtn ng-scope">Make Appointment</button>
</div>
<div class="col-xs-12 col-md-6 ng-scope">
<div class="col-xs-12">
<img ng-src="https://garageapi.herokuapp.com/tag_tab_icons/Tools/icon-tool-darkblue-25.png" src="https://garageapi.herokuapp.com/tag_tab_icons/Tools/icon-tool-darkblue-25.png"> Tools</div><!-- end ngRepeat: tag in other.tags | limitTo: 1 -->
<div class="col-xs-3"><img src="http://www.carlotfinance.com/assets/img/car_placeholder.jpg" alt="placeholder image"></div>
<div class="col-xs-8">
<h2>Pizza Place
<div class="glyphicon glyphicon-road"></div>
<div class="glyphicon glyphicon-unchecked"></div>
</h2>
<p>1234 M Ave, Austin, TX 27000</p>
<p>(555) 400 2800</p>
</div>
<button type="button" class="btn col-xs-12 makeAppointmentBtn ng-scope">Make Appointment</button>
</div>
</body>
</html>