How to force two buttons into one line - html

Below you see the cell where the buttons (bootstrap 4) are. The other cells were not printed. The EDIT and DELETE button are one over the other (2 lines). How to force them to the same line?
<div class="container">
<table class="table table-striped">
..deleted...
<tbody>
..deleted...
<tr>
<div>
<form method="GET">
{% csrf_token %}
<button class="btn btn-outline-secondary btn-sm" type="submit" name="edit"
value={{objekt.id}}>Edit</button>
</form>
<div id="colwrap">
<form method="POST">
{% csrf_token %}
<button class="btn btn-outline-secondary btn-sm" type="submit" name="delete"
value={{objekt.id}}>Delete</button>
</form>
</div>
</div>
</tr>
</tbody>
</table>
</div class="container">

I finally found an answer (https://www.w3schools.com/howto/howto_css_button_group.asp) (with additional CSS).
In the html:
<div class="btn-group">
<button>Apple</button>
<button>Samsung</button>
<button>Sony</button>
</div>
In the CSS (in my case in APPfolder/static/app.css):
.btn-group button {
background-color: #4CAF50; /* Green background */
border: 1px solid green; /* Green border */
color: white; /* White text */
padding: 10px 24px; /* Some padding */
cursor: pointer; /* Pointer/hand icon */
float: left; /* Float the buttons side by side */
}
.btn-group button:not(:last-child) {
border-right: none; /* Prevent double borders */
}
/* Clear floats (clearfix hack) */
.btn-group:after {
content: "";
clear: both;
display: table;
}
/* Add a background color on hover */
.btn-group button:hover {
background-color: #3e8e41;
}

Related

Button click working only if i click right hand side of button

A button name in my html has two text, when I click the second text only the button click is working. Need to make the entire button clickable and show pointer cursor when I mouse over.
<div class="d-flex">
<button (click)="myfunction()" type="button" class="btn btn-primary" *ngIf="currentPath!=
'/users/userlist'">Car List</button>
</div>
It's simple: cursor: pointer;
Just like this:
.d-flex {
display: flex;
justify-content: center;
align-items: center;
}
.d-flex .btn {
border: 1px solid #000;
background-color: #000;
color: #fff;
padding: 10px;
cursor: pointer;
}
<div class="d-flex">
<button (click)="myfunction()" type="button" class="btn btn-primary" *ngIf="currentPath!=
'/users/userlist'">Car List</button>
</div>
See more at: https://developer.mozilla.org/en-US/docs/Web/CSS/cursor .

Add html icon in button value

<input type="submit" id="appCreate" name="Reds" value="Reds" formaction=#Url.Action("") formmethod="post" class="btn btn-success btn-block" onclick="javascript: return SubmitForm(this);" />
CSS -
.reddot {
content: "\25cf";
font-size: 1.5em;
color: red;
}
I want to add <span class="reddot"></span> to the value of my button (it just creates a red dot icon). So the value of my button shown is Reds<red dot icon>
How can I do this?
Instead of content: "\25cf"; Try background: url('xyz.png');
<input> elements are considered void elements, therefore they cannot contain children. You could use a <button> element, but personally I'd discourage this method because the HTML spec deems it invalid.
One possible solution is to wrap the button in a container. That container could have a pseudo-element (::after) that places the red dot for you.
.reddot {
display: inline-block;
position: relative;
}
.reddot > input[type=submit] {
text-align: left;
padding-right: 20px; /* Add padding to make space for the dot */
}
.reddot::after { /* Place an element inside of .reddot */
display: block;
position: absolute;
top: 50%;
transform: translateY(-50%); /* Center it vertically */
right: 5px; /* 5px off the right edge */
content: "\25cf";
font-size: 1.5em;
color: red;
pointer-events: none; /* Make sure the dot doesn't block the button */
}
<div class="reddot">
<input type="submit" />
</div>
<div class="reddot">
<input type="submit" value="Here's another button with a red dot!" />
</div>

HTML need a button that will change an output of another button

I'm doing a little HTML project, I Have a Main CSS code the HTML that I'm stuck on,
I have (as you'll see in my code) a dropdown button which gives you several options, Now what I want is for when you click one of the options-
1. It shows the option in the main dropdown button (The text on it [Changing from "$4-$30 Aud" to whatever they pick])
and I want somehow for the "Add to cart" button to change to code that would redirect to what has been picked above it (the options mention above)
Anyway thanks for you help
CSS:
.button {
background-color: #ffffff;
border: none;
color: black;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 1px 2px;
cursor: pointer;
}
ul {display: inline;
list-style-type:none;
text-decoration: none;}
.button:hover{
background-color: #595959;
}
.header {
text-align: center;
background-color: #2ac9b7;
color: black;
position: fixed;
width: 100%;
padding: 20px;
}
html, body{
width:100%;
height:100%; background-color: #62666d; margin: 0px;
}
h1 {
font-weight:bold;
color: #000000;
font-size:42px;
}
.main {
font-family: arial;
margin: 0px;
}
.Content {
top:0;
bottom:0
left:0;
right:0;
margin-top: 160px
}
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {background-color: #f1f1f1}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn {
background-color: #3e8e41;
}
img
{
display: block;
margin: 0 auto;
}
HTML
<html>
<head>
<link rel="stylesheet" href="Masters_baby.css">
<div class="Main">
<div class="header">
<div class="links">
<ul><button class="button">Home</button> </ul>
<ul><button class="button">Shop</button></ul>
<ul><button class="button">Art</button></ul>
<ul><button class="button">About Me</button></ul>
<ul><button class="button">Support</button> </ul>
<ul><button class="button">Production</button></ul>
</div>
</div>
</div>
</div>
<IMG STYLE="position:absolute; TOP:23px; LEFT:20px; WIDTH:130px; HEIGHT:50px" SRC="Logo.png">
</head>
<body>
<IMG STYLE="TOP:180px; LEFT:30px; WIDTH:50px; HEIGHT:50px" SRC="Flame.png">
</body>
</div>
</div>
<div class="parallax"></div>
<div style="height:4950px; width:80%; margin:0 auto; background-color:#98eacc; margin-top: 44px">
<div class="Products" style="padding-top: 50px;">
<div class="∞ Frosted Kumquat" style= "width: 100%; height:9.1%; width:80%; margin:0 auto; background-color:#fff; ">
<p style="font-size: 25px">∞ Frosted Kumquat</p>
<IMG STYLE="WIDTH:35%; HEIGHT:63%" SRC="candle.jpg" >
<table style="width: 100%;">
<tbody>
<tr>
<td style="width: 80%;">A fresh citrusy smell that fills the room, Its is fairly stong washing out any unwanted smells or just lifting the room. Best for someone who doesnt like the smell of overly sweet but likes the fresh smell of fruit.</td>
<td>
<div class="dropdown"><button class="dropbtn">$4-$30 AUD</button>
<div class="dropdown-content">Melts $4.00 Tea light(6) $5.00 Candle in a Tin $14.00 Specitally Candles $15.00-$30.00 Boxed candle $22.00 Triplet pack of candles $28.00</div>
</div>
</td>
</tr>
<tr>
<td></td>
<td>
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<!-- Identify your business so that you can collect the payments. -->
<input type="hidden" name="business" value="kin#kinskards.com">
<!-- Specify a PayPal Shopping Cart Add to Cart button. -->
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="add" value="1">
<!-- Specify details about the item that buyers will purchase. -->
<input type="hidden" name="item_name" value="Birthday - Cake and Candle">
<input type="hidden" name="amount" value="3.95">
<input type="hidden" name="currency_code" value="USD">
<!-- Display the payment button. -->
<input type="image" name="submit"
src="Add2Cart.png"
alt="Add to Cart" STYLE="WIDTH:70%; HEIGHT:20%">
<img alt="" width="1" height="1"
src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif">
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</html>
Again Thanks for any help :)
First of all, place all of your content in the <body>. Your head is where you link to stylesheets, load scripts and set meta-data etc. you don't want to have any content such as your header in the head.
You can achieve things like this with JavaScript. Let me give you an example.
Lets say we have the following HTML:
<select class="selector">
<option value="10">10$</option>
<option value="20" selected>20$</option>
<option value="30">30$</option>
</select>
Selected plan: <span class="selected_plan">20$</span>
We want to change the content of the span with class selected_plan to the value selected in our select element.
First we need to create a new script (load your scripts at the bottom of your body).
<script> // place your script here </script>
or
<script src="link_to_your_js_file.js"></script>
Next we need to select our elements like so:
let selector = document.querySelector('.selector');
let selectedPlan = document.querySelector('.selected_plan');
Then we listen for when the select changes:
selector.addEventListener('change', function() {
selectedPlan.innerHTML = selector.value + '$';
});
I created this JSFiddle for you so you can experiment with this particular example: https://jsfiddle.net/dgyyyoh8/1/
EDIT:
If I'm correct you want to change attributes as well. You can use the setAttribute method for this.
let link = document.querySelector('.element');
link.setAttribute('href', selected.value);
Take a look at this JSFiddle: https://jsfiddle.net/dgyyyoh8/2/
Select our element
Create an event for when the selector changes
Set the innerHTMl of the link equal to 'Go to (text of the option)'
Set the href attribute equal to the selected options' value.
EDIT:
There are ways to change the appearance of the select element.
For example: https://codepen.io/ericrasch/pen/zjDBx
I'd suggest you also take a look at the CSS Framework Bootstrap. This framework contains a lot of classes you can work with to really take your styling to the next level.

Vertical Align Header with Alert and Button

I'm trying to vertically align a title header, an alert and two buttons.
My goal is to make the width of the alert bigger even if its content is short. My problem is that since I uses span for the alert, I need to put display: inline-block in its style but by doing that, the alignment with the header gets misaligned. BTW, I'm using Bootstrap.
Here's the image of what I want to happen:
Here's my HTML:
<h1>
<span>This will be a very long title</span>
<span class="alert custom">
This is notification!
</span>
<span class="pull-right">
<button class="btn button-round">O</button>
<button class="btn button-round">X</button>
</span>
</h1>
Here's my CSS:
.button-round {
border-radius: 50%;
color: white;
background: green;
}
.custom{
font-size: 12px;
vertical-align: middle;
background: green;
color: white;
}
Here's a jsfiddle of my current code:
JSFiddle of my current code
To make this easy, you should use flex :
.button-round {
border-radius: 50%;
color: white;
background: green;
margin: auto
}
.custom {
font-size: 12px;
vertical-align: middle;
background: green;
color: white;
/* added */
flex: 1;
margin: 0 0.25em;
}
h1 {
display: flex;
}
/* end added */
<!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>-->
<h1>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<span>This will be a very long title</span>
<span class="alert custom">
This is notification!
</span>
<span class="pull-right">
<button class="btn button-round">O</button>
<button class="btn button-round">X</button>
</span>
</h1>
https://jsfiddle.net/fczbe58L/1/

Remove white space from table cell

I have the following table:
<table>
...
<td>
<div class="btn-group btn-group-sm">
<button class="btn btn-info mini"><span class="glyphicon glyphicon-duplicate"></span></button>
<button class="btn btn-default mini">09:00</button>
<button class="btn btn-default mini">09:30</button>
<button class="btn btn-default mini">10:00</button>
<button class="btn btn-default mini">10:30</button>
<button class="btn btn-default mini">11:00</button>
<button class="btn btn-default btn-block chev down"><span class="glyphicon glyphicon-chevron-down"></span></button>
</div>
</td>
jsfiddle
And I want to remove the extra space next to my button-group so that there's little margin on either side. Each button has a fixed width and so does the button group:
CSS:
.btn-group {
width: 117px;
}
.btn-group-sm > .btn.mini {
padding: 5px 3px;
width: 40px;
}
.btn-group > .btn.mini:first-child:not(:last-child):not(.dropdown-toggle) {
border-radius: 0;
}
.btn-group > .btn.mini:first-child {
margin-left: -1px;
}
.btn-group-sm>.btn.mini,
.btn.chev {
border-radius: 0px;
}
.btn.chev {
width: 118px;
}
I've already tried using margin: 0 and trying to fix the column width, but with no luck so far.
On your table there is a padding:5px; you have to overwrite it with the following:
table.table {
width: auto;
margin:0 auto;
}
/** only for the head of the table. */
table.table thead th {
padding:0;
}
/** only for the body of the table. */
table.table tbody td {
padding:0;
}
Make sure you place this CSS after the CSS of Bootstrap! Additonaly remove all classes on the th (named col-md-1). The space should be removed like this example: https://jsfiddle.net/sebastianbrosch/3obsbh5n/2/
There appears to be a padding of 5px tied to table-condensed tbody>tr>td in the Bootstrap CSS. You can override this with your own style is several ways. A simple example would be to add a class to some td elements where you are going to have buttons:
<td class="buttonCell">
And override the Bootstrap style by using something like this:
.table-condensed tbody>tr>td.buttonCell {
padding: 0px;
}