How to style text of submit button - html

I have a link styled as follows:
<style>
.addNew{
background-color: #FFF;
display: block;
margin-top: 10px;
padding: 20px;
color: #08c;
border:3px dashed #08c;
cursor: pointer;
width: 100%;
box-sizing: border-box;
font-size: 1em;
}
</style>
<a class='addNew'>
<i class="fa fa-plus" ></i> Add new
<span style='text-decoration:underline'>Object</span>
</a>
I am using a span-tag inside the text and a font-awesome icon.
How can I use this for an submit button? I tried this:
<input type='submit' class='addNew' value="Add new Object">
But I have no idea how to style the text of the submit button.

Use a button element.
<button class='addNew'>
<i class="fa fa-plus" ></i> Add new
<span style='text-decoration:underline'>Object</span>
</button>
… then you can have child elements and target them independently for styling.

You can use <button>
<button><i class="fa fa-plus"> Add new <span style="text-decoration:underline;">Object</span></button>
Button behaviour is different then <input type="button"> or <input type="submit">. You can append elements in <button>.

You can also use <button> tag for submit. You need to also give the button a type of submit to capture the browser event.
<button type="submit">
<a>link</a>
<span>span</span>
</button>
EDIT: Why you should specify type of submit
<form>
<input />
<button type="button">not a submit button</button>
<button type="submit">submit button</button>
</form>
In this case, anyone looking at your code will know exactly which <button> is the actually submit button in a second. Also, if someone is going to get the form's submit button with CSS selector, one can easily do so by button[type="submit"]. Yes submit is the default type, but it is also the better practice for readability and easier for debugging.

Related

Not able to see entire text when embeded clear button in inputbox

In Angular, I have added clear button inside input box but after adding it I am not able to see entire text in input box as it is being overlapped. Please find detailed information below.
HTML Code
<ng-template pTemplate="input">
<input pInputText type="text" class="col-input-grid-100" >
<span class="mar-left">
<button (click)="clearmail1(ri)" style="border:none; outline: none; position: relative; width:0;background-color: #fff;">
<i class="pi pi-times"></i>
</button>
</span>
</ng-template>
CSS content
.col-input-grid-100{
width: 135%;
margin-left: -10px;
}
.mar-left{
margin-left:-29px;
}
Current Output: Text in input box is test3#test.com.
As you can see in above image "com" is not visible clearly. I tried multiple ways but things didnt work. Kindly help me to resolve this issue.
Note:
1. I want to show cross button inside input box only
2. I am not using bootstrap library.
I tried with below code and it worked for me.
<span class="p-input-icon-right">
<i class="pi pi-times" (click)="clearmail1(ri)" style="margin-right: -16px;"></i>
<input id="email1" class="col-input-grid-100" type="text" pInputText >
</span>
Output

Bootstrap input button not render with color

I wish to add a font awesome icon beside my input button.
So, I found this answer and only option 1 apply to my use case since I need to submit a form to delete repository.
But the input button does not match the color of span tag.
I tried to add btn-danger class into input tag but it has shadow.
https://jsfiddle.net/coolwei/4osuyrk5/6/
What I want to achieve is a consistent color and button size with View and Add button.
First of all, you should use <button> tag.
However, if you really have to do this that way, you should clear default input styles like this:
.clear-input {
background: none;
color: inherit;
padding: 0;
border: 0;
}
And add this class to your input
<input class="clear-input" type="submit" value="Delete">
https://jsfiddle.net/2vdabphn/
I'm not sure why you're nesting a button inside an a here.
<a href="#">
<button type="button" class="btn btn-success mr-1">
<i class="fas fa-user-plus"></i>
Add Student
</button>
</a>
For your submit button, what you want to do is use the button tag with the type="submit" property.
<button type="submit" class="btn btn-danger">
<i class="far fa-trash-alt"></i>
Delete
</button>

Change color of glyphicon

I used this html code to show a color of a project:
<span class="glyphicon glyphicon-folder-open" data-ng-style="{'color': projectUserConnection.project.color}"></span>
now I will provide to change the color in that way that if glyphicon is clicked a color chooser should be opened. Does anyone know how to include or something else
<input type="color">
into the span or how I can do it?
try this: JSCOLOR
CODE
You can find all information on their site by the way for make the answer complete i add there the example code from the site that i think you will need to use.
<script src="jscolor.js"></script>
<p>You can add the color picker to a BUTTON:
<button class="jscolor {value:'66ccff'}"></button>
<p>... which might be empty to just display the color:
<button
class="jscolor {valueElement:null,value:'66ccff'}"
style="width:50px; height:20px;"></button>
<p>... and can be styled too:
<button
class="jscolor {valueElement:null,value:'66ccff'}"
style="border:2px solid black">
Pick a color
</button>
Please tell me if this is something that can help you!
<span class="glyphicon glyphicon-user" style="color:blue"></span>
HTML
<span class="glyphicon glyphicon-user blue"></span>
CSS
.blue {
color: blue;
}

adding image in url action link inside input button?

I want to add image button inside an input button which has url.action method
<input type="button" class="btn btn-primary" value="View Chart" onclick="location.href='#Url.Action("Multigraph", "Home")'"/>
Actually i want to do this
On click of the image i will be able to go to the specific view
I have also looked into this link
Any help will be appreciated
You could style the input button with css.
.btn--graph {
width: 110px;
height: 93px;
background-image: url('http://i.stack.imgur.com/jCvdY.jpg');
}
<input type="button" class="btn btn-primary btn--graph" onclick="location.href='#Url.Action("Multigraph", "Home")'"/>
However if this button is actually a link to another webpage. It would semantically be more correct to use an anchor link.
<a href="#Url.Action("Multigraph", "Home")">
<img src="http://i.stack.imgur.com/jCvdY.jpg" alt="View Chart">
</a>

How would I change the color of one word in the button?

How would I change the color of one word in the button?
I've tried using <input type="submit" value="lool <span style='color: red'>lool2</span"> but it just shows the code instead.
Give it a span and give the span a specific color.
HTML:
<button type="button">
<span class="color">Click</span>Me!
</button>
CSS:
.color{
color: red;
}
Try this:
<button>One<span style="color: red">Two</span></button>