I have a small question.
What would be the best way to make a sibling push on the last element of said div?
this is the structure:
<div class="row">
<div class="formContainer col-lg-6">
<form>
<fieldset>
...content....
<button>Submit Form</button>
</fieldset>
</form>
</div>
<div class="col-lg-6" id="datePicker">
calendar where user picks dates
</div>
</div>
and the CSS (more or less)
form > button {
width: 200px;
margin: auto;
display: block;
margin-bottom: 15px;
position: relative;
right: -54%;
}
Here is an image as an example:
I want the right col-6 div to push on the save button which is in the left col-6, because there are elements of the rightmost div that are being added that start overlapping. How should I go about doing so?
This will do it:
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<div class="row">
<div class="formContainer col-lg-6">
<form>
<fieldset>
...content....
</fieldset>
</form>
</div>
<div class="col-lg-6" id="datePicker">
calendar where user picks dates
</div>
<div class="col-lg-12 text-center">
<button class="btn btn-default"
onclick="$('.formContainer form', $(this).closest('.row')).submit();">Submit Form</button>
</div>
</div>
Notice I moved the button in a new column and I'm using inline Javascript to submit the form when it's pressed.
Related
I'm trying to create a virtual roulette wheel. Right now my concerns are strictly aesthetic. In the text-well on the right, the number in the #chipsInv won't center, except when I put an html "center" tag, and then for some reason it creates a huge amount of empty space at the bottom.
Here is my code, I've left out the Javascript since I assume it's irrelevant:
<!DOCTYPE html>
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<style>
#ball {
position: absolute;
left: 208px;
top: 40px;
z-index: 1;
width: 20px;
height: 20px;
transition: top 1s;
}
#wheel {}
form {}
.row {
padding: 20px;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-lg-5">
<img id="ball" src="ball.png" onclick="spin()"></img>
<img id="wheel" src="Rwheelbg.png" onclick="spin()"></img>
</div>
<div class="col-lg-1">
<button id="reset" onclick="reset()">Reset</button>
</div>
<div class="col-lg-6">
<div class="well well-lg">
<span><center>Chips</center></span>
<br>
<span style="font-size: 180px; text-align: center;" id="chipsInv">10</span>
<!-- Why won't this center!? -->
<br>
<span style="float:right;" id="purchase"><a style = "color:green !important;" href = "#">$ Purchase More Chips?</a></span>
</div>
</div>
<!-- Row ends here -->
</div>
<p>Bet on:</p>
<form action="">
<input type="checkbox" name="21" value="310" id="310"> 21
<br>
<input type="checkbox" name="9" value="100" id="100"> 9
<br>
<input type="checkbox" name="14" value="120" id="120"> 14
<br>
<input type="checkbox" name="13" value="240" id="240"> 13
</form>
<p>Bet on up to four numbers. However, be warned, the more numbers you bet on, the lower your chip return will be.</p>
<!-- container ends here -->
</div>
</body>
</html>
In Bootstrap, as best you can / where you can, use the Bootstrap classes to provide the styling you're looking for, as the Bootstrap classes are designed to be compatible with one another.
<div class="col-lg-6">
<div class="well well-lg">
<div class="text-center">Chips</div>
<div class="text-center" style="font-size: 180px;" id="chipsInv">10</div>
<div class="float-right" id ="purchase"><a style = "color:green !important;" href = "#">$ Purchase More Chips?</a></div>
</div>
</div>
If you want to text center everything in your example you can simply add the text-center class next to your well well-lg classes, as follows :
<div class="col-lg-6">
<div class="well well-lg text-center">
<div>Chips</div>
<div style="font-size: 180px;" id="chipsInv">10</div>
<div class="float-right" id ="purchase"><a style = "color:green !important;" href = "#">$ Purchase More Chips?</a></div>
</div>
</div>
Additionally;
with Bootstrap, they recommend you use div's where possible, and then
you can specify different behaviour by modifying the classes of those
divs, such as "d-inline", or "d-block". That was the reason I changed
your spans to divs.
Ensure your col-lg-6 div is contained within a div with class "row", and that according to the docs, these divs specifying col div when added together do not exceed 12. Bootstrap Grid Docs
As you can see in the fiddle here:
https://jsfiddle.net/qar4n4ey/6/
The two buttons at the bottom are partially outside the container. It happened when i floated them both left and right. How to keep them inside the container?
HTML:
<!DOCTYPE html>
<html>
<head>
<title>MYMDB</title>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.css">
<link rel="stylesheet" type="text/css" href="/stylesheets/app.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<div class="ui main center aligned text container segment">
<div class="ui huge header">Search for a TV show</div>
<form class="ui form" action="results" method="GET">
<div class="ui search">
<div class="ui icon input">
<input class="prompt" type="text" placeholder="Tv shows..." name="search">
<i class="search icon"></i>
</div>
<div class="results"></div>
</div>
<input id="greenbtn" class="ui green button" type="submit">
</form>
<a id="run" href="/run" class="ui left floated blue animated button" tabindex="0">
<div class="visible content">Run python</div>
<div class="hidden content">
<i class="terminal icon"></i>
</div>
</a>
<a id="show-data" href="/data" class='ui right floated disabled button'> See the table </a>
</div>
</body>
</html>
And some css
#greenbtn {
margin-top:10px;
}
All the given answers don't use functionality of Semantic UI. If you want to do it in Semantic UI way then you can use clearing serment:
<div class="ui main center aligned text container clearing segment">
</div>
Use float: left for the container also
.ui.container{
float: left; // you could also use display: inline-block;
width: 100% !important;
}
Add clear: both after floated elements, or overflow: hidden to parent box.
.main.container {overflow: hidden}
https://jsfiddle.net/qar4n4ey/12/
I have just added a Bootstrap panel which sits above a table of search results - this is my first time working with Panels. The panel includes a form with a select menu - the idea is that users can make selections which will filter the list of search results.
At the moment the panel has the same width as the table and the select menu is also very wide - I would like to reduce the width of the Panel by around 1/3 and have it centred on the page but not sure if this is possible or how to do this.
Here's my HTML for this:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="text-center">
<ul class="pagination">
<li class="disabled">First</li>
<li class="disabled">Previous</li>
<li>Next</li>
<li>Last</li>
</ul>
</div>
<div class="text-center">
<span class="counter-items"><span class="counter-num-items">1-20 / 13233</span></span>
</div>
<h1>Search Results</h1>
<br>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Filter By</h3>
</div>
<div class="panel-body">
<form class="form-horizontal" id="filter" action="filter.php" method="get" role="form">
<input type="hidden" name="action" value="filterSearch">
<div class="form-group">
<div class="col-sm-9">
<select class="form-control" name="productType" id="productType">
<option selected="selected">By Product Type</option>
<option value="Cars">Cars</option>
<option value="Trains">Trains</option>
<option value="Planes">Planes</option>
</select>
</div>
</div>
</form>
</div>
</div>
Place your panel inside a div tag with class="col-xs-offset-3 col-xs-6". find below
<div class=" col-xs-offset-3 col-xs-6">
<div class="panel panel-primary">
----
</div>
<div>
If I am correctly understanding you want to center and reduce width of your panel to 1/3.
So you should put an id (panel1) to the panel and add css
<div id ="panel1" class="panel panel-primary">
<style>
#panel1 {
width:30%;
height:auto;
margin:0 auto;
text-align:center;
}
</style>
Seems like you don't want to use Column Layout in your code. All though, it is possible to reduce the width of the panel and place it to the center of the page. You can override bootstrap's default CSS style for Panel. Try to add below code to your HTML file under <head> section:
<style>
#panel-center{
width: 20%;
margin: 0 auto;
}
</style>
Add id = "panel-center" to this line <div class="panel panel-primary">
This would solve your problem, but it is not optimum solution. I would suggest to use Column Layout(Grid).
Thank you.
I have this button that I need centered in the space between two other div's. I'm not the primary developer on this project... I was just brought in to help bang out some new features really fast. I don't want to overhaul the html of the primary developer (who is still very active on this project), so instead of converting this to bootstrap rows and columns, is there a less invasive way to center this button?
(PS what you see in the snippet isn't what it actually looks like. We are missing some CSS. But it's close enough for what I need done.)
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div>
<div class="text-right">
<div id="">
<div>
<strong>Exclude Customers With Tags: </strong>
<select id="" multiple style="width:100px;"></select>
</div>
</div>
<div class="pull-left" id="">
<label>
<input type="checkbox" value="" id="">
some text
</label>
</div>
<!-- This is what I am adding -->
<div class="pull-left">
<button id="" class="btn btn-primary btn-sm">Center Me</button>
</div>
<!-- end/ This is what I am adding -->
<div class="clearfix"></div>
</div>
<div class="clearfix"></div>
</div>
i have removed the standard classes from bootstrap and display it with the flex
.text-right {display: flex;
flex-direction: row;
justify-content: space-between;}`
here is a jsfiddle demo https://jsfiddle.net/jjx4cf8L/
I have the following CSS HTML code for a pop-up box.
I have inserted a division class .pop outside the container.
Now, I wish to hover on input with a placeholder="Where do you want to go?" so that the pop-up box's height increases to provide additional information on random locations.
How can I do this?
div.pop {
border: 2px solid red;
height: 0px;
position:absolute;
background-color: blue;
margin-top:-10px;
margin-left: 90px;
width: 400px;
}
div {
display:inline;
}
<div class="pop">
<div class="container">
<div class="row">
<div class="col-sm-4">
<input class="inp1" type="text" placeholder="Where do you want to go?" />
</div>
<div class="col-sm-4">
<input type="text" placeholder="Move in Date" />
</div>
<div class="col-sm-3"></div>
</div>
</div>
</div>
Its Simple, You can do this using JQuery or Javascript
JQuery Example:
$(document).ready(function() {
$('.inp1').hover(function(){
$('.pop').css('height','500px'); //This will expand
},function(){
$('.pop').css('height','0'); //This will go back to normal
});
});
CSS doesn't have selector for parents, only childs. You can do what you want with js. Or changing your structure
As CSS has no parent selectors, you probably going to need to use javascript for it.
var inputs = document.querySelectorAll('.parent-on-hover');
for( var i = 0; i < inputs.length; i++) {
this.addEventListener('mouseenter', function(e){
// find parent of .pop class and increase it's height
});
this.addEventListener('mouseleave', function(e){
// find parent of .pop class and decrease it's height
});
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<div class="pop">
<div class="container">
<div class="row">
<div class="col-sm-4">
<input class="parent-on-hover inp1" type="text" placeholder="Where do you want to go?" />
</div>
<div class="col-sm-4">
<input class="parent-on-hover inp1" type="text" placeholder="Move in Date" />
</div>
<div class="col-sm-3"></div>
</div>
</div>
</div>
What you can do is to add CSS transition property on the parent class and on mouseenter/leave add/remove another class with increased height. It will acomplish nice visual effect. Also what you can consider with text inputs is using focus/blur events instead, as they are more intuitional for users.