Add content to top-right area of rows - html

After various attempts with pull-right, float style and row-fluid, I decided to ask here:
What I try to do is simply to have a Map appear to the right of a set of rows.
Here is how it looks right now:
Which is not too far from what I want, but the name row plus any following rows should appear below each other.
Here is how my HTML looks:
<div class="panel-body">
<div class="row-fluid">
<div class="col-lg-10 pull-right">
<google-map id="my-map" bounds="map.bounds" events="map.events"
center="map.center" zoom="map.zoom" draggable="true"
control="map.control"> <marker ng-if="positionMarker"
coords="positionMarker" icon="positionMarker.icon"> </marker> </google-map>
</div>
<div class="col-lg-4">
<div class="input-group">
<span class="input-group-addon">Number</span> <input type="number"
class="form-control" placeholder="Nr">
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6">
<div class="input-group">
<span class="input-group-addon">Name</span> <input type="text"
class="form-control" placeholder="Name">
</div>
</div>
</div>
</div>
I bet this is a typical scenario but I have failed to find an example.
Other attempts that makes name appear below number, moves it below the map.
Is it perhaps possible to avoid having the map take up vertical space in the Bootstrap grid system?

You should use a 2-col layout :
Left column for your inputs
Right column for your Google Map
Plus, remember to put your .input-group inside a .form-group to get paddings/margins set to Bootstrap default values.
Here's a working example (click on Full page for a better view):
body {
padding-top: 25px;
}
.map {
width: 100%;
height: 150px;
background: tomato;
}
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Panel heading</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-xs-6">
<form role="form">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">Number</span> <input type="number"
class="form-control" placeholder="Nr">
</div>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">Name</span> <input type="text"
class="form-control" placeholder="Name">
</div>
</div>
</form>
</div>
<div class="col-xs-6">
<div class="map"></div>
</div>
</div>
</div>
</div>
</div>

Related

Is there a way to center a card in a container using Materialize CSS?

<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<body class="grey darken-4">
<div class="container">
<div class="row">
<!-- I have tried adding center, center-align as a class to div tags but it in correctly formats. My form elements to the center which was not what I except -->
<div class="col s12 m6 l10">
<!-- adding center, center- align to the row still doesn't fix the issues still -->
<div class="card">
<div class="card-content">
<span class="card-title center ">Loan Calculator</span>
<form action="">
<div class="input-group">
<div class="input-field">
<span>$</span>
<input type="number" class="form-control" placeholder="Amount">
</div>
<div class="input-field">
<span>%</span>
<input type="number" class="ïnput-field" placeholder="Loan" class="form-control">
</div>
<div class="input-field">
<input type="number" class="form-control" placeholder="Years To Pay">
</div>
<div class="center">
<input type="submit" value="CALCULATE" class="btn black">
</div>
<h5 class="text-darken-3 center " id="result">Results</h5>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
I don't know if this is a current issue with Materialize CSS itself.
My goal is to properly format the card so that it has 6 columns for medium display. However, the card, when resized to small width, behaves in a erratic manner (the content is aligned to the left, and the space on the right is left empty).
The cause of the "issue" (I would say it is by-design) is the combination of float: left; and margin-left: auto; with no margin-right: auto; rules applied for columns with .col.m* classes. Because of this, columns are always snapped to the left of the containing row.
If you want to override this to center your column, you need to specify an offset. What Materialize CSS Grid (implemented with float) expects you to do is to express that the column taking ½ of the containing row width should be offset by 6 divided by 2 columns on both sides (aka "centered").
Offsets in Materialize CSS are provided with the offset-* set of classes. In your case, you only need the offset-m* and offset-l* subsets. Let's take a look:
<link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<body class="grey darken-4">
<div class="container">
<div class="row">
<!-- I have tried adding center, center-align as a class to div tags but it in correctly formats. My form elements to the center which was not what I except -->
<div class="col s12 m6 l10 offset-m3 offset-l2">
<!-- adding center, center- align to the row still doesn't fix the issues still -->
<div class="card">
<div class="card-content">
<span class="card-title center ">Loan Calculator</span>
<form action="">
<div class="input-group">
<div class="input-field">
<span>$</span>
<input type="number" class="form-control" placeholder="Amount">
</div>
<div class="input-field">
<span>%</span>
<input type="number" class="ïnput-field" placeholder="Loan" class="form-control">
</div>
<div class="input-field">
<input type="number" class="form-control" placeholder="Years To Pay">
</div>
<div class="center">
<input type="submit" value="CALCULATE" class="btn black">
</div>
<h5 class="text-darken-3 center " id="result">Results</h5>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</body>

Positioning elements using Bulma CSS

I am trying to horizontally center some text with the search bar using Bulma CSS, but it didn't work out the way I wanted. I tried using columns, but they are usually pulled all the way over at the edge or not placed properly. I also tried using levels but they also had similar results that I didn't want. Please help.
Here is my code:
<div class="container section">
**<p> I want to make this tag to be in the same line as the search box </p>**
<div class="field has-addons is-pulled-right">
<div class="control">
<input class="input" type="text" placeholder="Search competition">
</div>
<div class="control">
<a class="button is-info">
Search
</a>
</div>
</div>
</div>
I want to have some text aligned to the left of the container and the search box located on the opposite right side of the row. Thank you.
Can you describe what issues you were having with the columns? Did you try using the .is-vcentered class on the .columns div?
Make sure to view the following code in a full screen.
<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.5/css/bulma.min.css" rel="stylesheet"/>
<div class="container section">
<div class="columns is-vcentered">
<div class="column">
<p style="border: 1px solid #ccc;"> I want to make this tag to be in the same line as the search box </p>
</div>
<div class="column">
<div class="field has-addons is-pulled-right">
<div class="control">
<input class="input" type="text" placeholder="Search competition">
</div>
<div class="control">
<a class="button is-info">
Search
</a>
</div>
</div>
</div>
</div>
</div>
OR I see that you said horizontally centered. Did you try the .is-centered class on the .columns container and the .is-narrow class on the .columns?
<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.5/css/bulma.min.css" rel="stylesheet"/>
<div class="container section">
<div class="columns is-centered is-vcentered">
<div class="column is-narrow">
<p style="border: 1px solid #ccc;"> I want to make this tag to be in the same line as the search box </p>
</div>
<div class="column is-narrow">
<div class="field has-addons">
<div class="control">
<input class="input" type="text" placeholder="Search competition">
</div>
<div class="control">
<a class="button is-info">
Search
</a>
</div>
</div>
</div>
</div>
</div>

Offset & Center Container w/Bootstrap

Im trying to center the header and input field with bootstrap. I cant get the input field to center with the header. If anyone has a better way of doing this let me know.
<div class="container">
<div class="row">
<div class="col-md-6">
<h1 class="display-4 text-center">Weight Converter</h1>
<form>
<div class="form-group">
<input
id="lbsInput"
type="number"
class="form-control form-control-lg"
placeholder="Enter Weight..."
/>
</div>
</form>
<div id="output">
<div class="card">
<div class="card-block">
<h4>Grams:</h4>
<div id="gramsOutput"></div>
</div>
</div>
</div>
</div>
</div>
</div>
you have incomplete HTML and no CSS. But based on what you have, a simple margin: auto; in CSS should center the element for you.
If you want more control you should look into flexbox. post more code and you'll get more help.
EDIT: thanks for the code: this works to center the input. I just verified it. let me know if you need any more help. cheers
<div class="container">
<div class="row">
<div class="col-md-6">
<h1 class="display-4 text-center">Weight Converter</h1>
<form>
<div class="form-group" id="centerParent">
<input
id="lbsInput"
type="number"
class="form-control form-control-lg"
placeholder="Enter Weight..."
/>
</div>
</form>
<div id="output">
<div class="card">
<div class="card-block">
<h4>Grams:</h4>
<div id="gramsOutput"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<style>
#centerParent {
display: flex;
flex-direction: row;
justify-content: center;
}
</style>

div positions are not being responsive css

I am trying to implement a single page application where I want divs to display one below the other. But on resizing the viewport to various screen sizes, the positioning is getting overlapped and leaving extra spaces in between. I have codepen example to explain the problem in a better way.
https://codepen.io/SaloniDesai/pen/zPBZJr
How to make the divs appear same for every screen size ?Do i need to shuffle the way I have created the layout of the page ?
<div id="headliner" class="jumbotron text-center">
<h1>SearchGIFY app</h1>
<p>search for any GIF you want!</p>
</div>
<div id="search">
<form>
<input type="search" ng-model="vm.search.gif" value="" placeholder="type what you're looking for" />
<button type="submit" class="btn btn-primary" ng-click="vm.performSearch()">Search</button>
</form>
</div>
<div class="row">
<div class="card">
<img ng-repeat="g in vm.giphies" ng-src="{{g.images.original.url}}" height="{{g.images.fixed_height}}" title="{{g.title}}">
</div>
</div>
<div class="jumbotron text-center" id="trendingBar">
<h3>Trending gifs</h3>
<div class="row">
<div class="thumbnail">
<img ng-repeat="trending in vm.trendingGifs" ng-src="{{trending.images.original.url}}" height="{{trending.images.fixed_height.height}}" title="{{trending.title}}">
</div>
</div>
</div>
First, your bootstrap structure isn't good, there isn't container, neither rows or col.
Try this one:
<div class="container-fluid">
<div class="row">
<div id="headliner col-md-12" class="jumbotron text-center">
<h1>SearchGIFY app</h1>
<p>search for any GIF you want!</p>
</div>
</div>
<div class="row">
<div id="search">
<div class="col-md-12">
<form class="form-inline text-center col-md-6 col-md-offset-3">
<div class="form-group">
<input class="form-control" type="search" ng-model="vm.search.gif" value=""
placeholder="type what you're looking for"/>
</div>
<button type="submit" class="btn btn-primary" ng-click="vm.performSearch()">Search</button>
</form>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="card">
<img ng-repeat="g in vm.giphies" ng-src="{{g.images.original.url}}" height="{{g.images.fixed_height}}"
title="{{g.title}}">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="jumbotron text-center" id="trendingBar">
<h3>Trending gifs</h3>
<div class="thumbnail">
<img ng-repeat="trending in vm.trendingGifs" ng-src="{{trending.images.original.url}}"
height="{{trending.images.fixed_height.height}}" title="{{trending.title}}">
</div>
</div>
</div>
</div>
Second, you add a lot of absolute class with % height and width. You don't have to do that if you're using bootstrap, all the responsive stuff is handled by the bootstrap grid with col classes. Take a quick look at the grid bootstrap documentation : https://getbootstrap.com/docs/3.3/css/#grid
Here's the codepen working responsively with some modification : https://codepen.io/anon/pen/MOemgw ;)

Aligning a checkbox and text in two different columns

I am working on a display where there are 3 checkboxes. When one of these checkboxes is triggered, a message or input field should appear. I got that part working, but the checkbox and the message are not aligned as shown in the image below
As you can see the "Ondertiteling" checkbox is not aligned with the text "Ondertitel enabled".
This is my code (with the toggling of the message ommitted for the question's sake)
.checkbox {
position: relative;
display: block;
margin-top: 10px;
margin-bottom: 10px;
}
.checkbox label {
min-height: 20px;
padding-left: 20px;
margin-bottom: 0;
font-weight: normal;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<span>Aanvraag #1</span>
<i class="fa fa-remove pull-right icon-clickable"></i>
</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-lg-3">
<div class="checkbox">
<label> <input type="checkbox">Ondertitels</label>
</div>
<div class="checkbox">
<label> <input type="checkbox">Vertaling</label>
</div>
<div class="checkbox">
<label><input type="checkbox">Voice-overs</label>
</div>
</div>
<div class="col-lg-9">
<div>Ondertitel enabled</div>
<div>Vertaling enabled</div>
<div class="text-danger">Voor voice-overs kan geen automatische prijsindicatie gegeven worden.</div>
</div>
</div>
</div>
</div>
</div>
</div>
How can I align the text to be on the same height as the checkbox? Thanks in advance.
I would ask to change your markup to fix the formatting so that bootstrap will handle it for us. Change the markup into rows such as this:
<div class="row">
<div class="col-lg-3">
<div class="checkbox">
<label><input type="checkbox">Vertaling</label>
</div>
</div>
<div class="col-lg-9">
<div class="checkbox">Vertaling enabled</div>
</div>
</div>
See demo below:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<span>Aanvraag #1</span>
<i class="fa fa-remove pull-right icon-clickable"></i>
</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-lg-3">
<div class="checkbox">
<label><input type="checkbox">Ondertitels</label>
</div>
</div>
<div class="col-lg-9">
<div class="checkbox">Ondertitel enabled</div>
</div>
</div>
<div class="row">
<div class="col-lg-3">
<div class="checkbox">
<label><input type="checkbox">Vertaling</label>
</div>
</div>
<div class="col-lg-9">
<div class="checkbox">Vertaling enabled</div>
</div>
</div>
<div class="row">
<div class="col-lg-3">
<div class="checkbox">
<label><input type="checkbox">Voice-overs</label>
</div>
</div>
<div class="col-lg-9">
<div class="checkbox text-danger">Voor voice-overs kan geen automatische prijsindicatie gegeven worden.</div>
</div>
</div>
</div>
</div>
</div>
</div>
Well the solution of your problem is to create three separate rows and one row spanning total 12 columns, for which you will use 3 for one checkbox and other for your notification or message.
So each message and check box will be bundled together in container or row class.
Will provide code shortly, if you don't understand what I am trying to say
remove the 10px margin-top from your checkbox class or add it to the othediv. I think this is what cause your offset. :)
Ok so you just need to add margin-top: 10px and margin-bottom: 10px to your div inside the col-lg-9
The answer you are probably searching is just changing the line or font height in your lg9 div
or using only one column, with checkbox and label having a constant width