I want to make a buttons that looks like:
I tried this:
css:
button {
color: #900;
border: 1px solid #900;
font-weight: bold;
width: 200px;
height: 100px;
}
button img {
margin-right: 5px;
vertical-align: middle;
}
html:
<button class="btnExample" type="submit" value="Submit">
<img src="./images/img04.jpg" width="18" height="18" alt=""/>Submit</button>
And result:
Why image so small(18*18px)? How to make image bigger?
change this to increase size
<img src="./images/img04.jpg" width="28" height="28" alt=""/>Submit</button>
to change size change width=" " and for height=" "
button {
color: #900;
border: 1px solid #900;
font-weight: bold;
width: 200px;
height: 100px;
}
button img {
margin-right: 5px;
vertical-align: middle;
}
<button class="btnExample" type="submit" value="Submit">
<img src="http://4vector.com/i/free-vector-kuba-arrow-button-set-clip-art_117492_Kuba_Arrow_Button_Set_clip_art_hight.png" width="58" height="58" alt=""/>Submit</button>
The image is as big as you make it. From your comments, it seems that the actual size of the image is 18 by 18 pixels. I would be possible to stretch it by setting larger values for the width and height attributes or by setting the width and height properties to suitable values in CSS. However, scaling upwards may produce graphically poor results for raster images like jpeg images.
It is therefore better to use a graphics program to create the image in the desired size and change the width and height attributes to match the new size.
Related
I have a button which when pressed revokes a user's access token. I want to make it look like the Sign in with Slack button.
I am attaching the html code for the Sign in with Slack Button below.
<a href="https://slack.com/oauth/authorize?scope=identity.basic,identity.email,identity.team,identity.avatar&client_id=373568302675.374024189699">
<img alt="Sign in with Slack" height="40" width="172" src="https://platform.slack-edge.com/img/sign_in_with_slack.png" srcset="https://platform.slack-edge.com/img/sign_in_with_slack.png 1x, https://platform.slack-edge.com/img/sign_in_with_slack#2x.png 2x"
/>
What do I need to do to make my button look the same?
For now, the code for my button is as under:
<input type="button" value="Unlink Slack" onclick="location.href='#Url.Action(" RevokeAuth ","Settings ")'"/>
Is this what you were looking for I added the input to a div with the slack image and added the onclick to the div as well as the button so the pointer looks correct.
<style>
.slk {
border: 1px solid #C8C8C8;
width: 170px;
width: 170px;
border-radius: 5px;
display: flex;
height: 35px;
cursor: pointer;
}
.slkInp {
color: #383838;
background-color: white;
border: none;
padding: none;
font-size: 15px;
font-weight: bold;
}
.slkInp:hover {
cursor: pointer;
}
</style>
<div class="slk" onclick="location.href='#Url.Action(" RevokeAuth ","Settings ")'">
<img alt="Unlink Slack" height="30" width="30" style="padding-left:10px;" src="https://pbs.twimg.com/profile_images/885554951857946624/sd7GRyjY_400x400.jpg" /><input class="slkInp" type="button" value="Unlink Slack" onclick="location.href='#Url.Action("
RevokeAuth ","Settings ")'"/></div>
<a href="https://slack.com/oauth/authorize?scope=identity.basic,identity.email,identity.team,identity.avatar&client_id=373568302675.374024189699">
<img alt="Sign in with Slack" height="40" width="172" src="https://platform.slack-edge.com/img/sign_in_with_slack.png" srcset="https://platform.slack-edge.com/img/sign_in_with_slack.png 1x, https://platform.slack-edge.com/img/sign_in_with_slack#2x.png 2x"
/>
First off, I can't ask for clarification in a comment because of the 50 reputation requirement. Fair enough.
What it seems like you're asking is how do you want to style a button to look like the Slack button, but with only HTML? All they are doing here is using an <img> tag to throw a button on the screen. If you want to copy this behavior exactly, grab an image editor and draw a rounded rectangle with 1px black border, throw your icon on the right and some text on the left then follow the slack design:
<a href="https://linkhere.link">
<img alt="Sign in with X" height="40" width="172" src="image.png" />
</a>
If you want to be able to have a button styled similarly with just HTML and CSS you can do that too, with your input:
input {
height: 40px;
width: 172px;
border: 1px solid gray;
border-radius: 5px;
background-color: white;
content: url(image.png);
...
}
Then add your own image and move the text and image to your liking.
I'm working on this HTML email template and thought I was done until I figured out that GMail and some other e-mail clients strip out the position CSS property.
Since writing html/css for email readers is like going back into the stone ages I'm a little bit stuck on this one.
What I want is to display a score bar which is sort of like a progress bar, with a score text inside of it, like this:
This works fine until the score becomes really low and the score text doesn't fit inside of the blue container anymore. The text just gets cuts off like so:
and at 0%:
Please note that I'm not sure why the word "Score" still shows up in the last one.
What I want is the score text just to overlap into the red part when the text is too long to fit inside of the blue container.
My code is as follows:
<div style="float: left;width: 70%;height: 30px;max-height: 30px;background-color: #f00;color: #fff;font-weight: bold;padding: 0px;font-size: 18px;">
<div style="float: left;width: 0%;height: 30px;max-height: 30px;margin: 0;padding: 0;background-color: #3c88a7;overflow: visible;">
<div style="padding-left: 10px; float: left;line-height: 30px;max-height: 30px;">Score 0%</div>
</div>
</div>
I've also tried to solve it with a table, but I walk into the same problem - there seems to be no cross-platform way to make the text overflow the cell.
Any ideas how to solve this, so it works in all the major email clients and webmail clients?
It is as simple as this:
<div style="margin:0;padding:0;background:blue">
<p style="width:10%;background:red;color:white;white-space: nowrap;">Score: 10%</p>
</div>
not very polished, but at least for a code-starter it's fine, i guess
You could use just two div without positioning. You have to use white-space: nowrap to prevent your text from wrapping.
Example Snippet:
div.wrap {
width: 100%; height: 26px; max-height: 26px;
background-color: #dd6666; color: #333;
padding: 0px;
}
div.wrap > div {
line-height: 26px; max-height: 26px;
background-color: #3c88a7; padding: 0px 0px 0px 4px;
width: 30%; white-space: nowrap; color: #fff;
font-family: helvetica, sans-serif; font-size: 14px; font-weight: bold;
}
div.d2 > div { width: 5%; }
div.d3 > div { width: 15%; }
div.d4 > div { width: 0%; }
div.d5 > div { width: 60%; }
<div class="wrap d1">
<div>Score 30%</div>
</div>
<br /><div class="wrap d2"><div>Score 5%</div></div>
<br /><div class="wrap d3"><div>Score 15%</div></div>
<br /><div class="wrap d4"><div>Score 0%</div></div>
<br /><div class="wrap d5"><div>Score 60%</div></div>
Here's a completely insane solution. :)
I wrote the SVG to CSS here...
http://jsfiddle.net/coqckyj9/1/
Then converted the SVG to base64 and pasted it into the div background image...
http://jsfiddle.net/coqckyj9/2/
<div id='bar' style='width: 100px; height: 20px; background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnPjxyZWN0IGZpbGw9J2JsdWUnIHdpZHRoPSc0cHgnIGhlaWdodD0nMjBweCcgLz48cmVjdCBmaWxsPSdyZWQnIHg9JzRweCcgIHdpZHRoPSc5NnB4JyBoZWlnaHQ9JzIwcHgnIC8+PHRleHQgeD0nMnB4JyB5PScxNnB4JyBmaWxsPSd3aGl0ZScgZm9udC1zaXplPScxOCc+U2NvcmUgNCU8L3RleHQ+PC9zdmc+);'></div>
I have this simple layout:
<form>
<div>
<input class="buttonStyle" type="submit" name="action" value="Press this button to do Action A">
</div>
<div>
<input class="buttonStyle" type="submit" name="action" value="Press this">
</div>
<div>
<input class="buttonStyle" type="submit" name="action" value="Press!">
</div>
</form>
I use this simple style so that the buttons are big and are have some space between them:
.buttonStyle {
margin-bottom: 10px;
border: none;
cursor: pointer;
font-size: 20px;
border-radius: 5px;
}
The problem I have is that the buttons do not have the same size (since it seems that the size of the button is the same as the size of the text) and form a scale (i.e. big, short, shorter).
How can I make the buttons have the same size irrespective of the containing text?
Just add a width property to the button CSS.
For example:
.buttonStyle {
//...
width: 100px;
}
set a width attribute in your CSS
like so:
.buttonStyle {
margin-bottom: 10px;
border: none;
cursor: pointer;
font-size: 20px;
border-radius: 5px;
width: 200px;
}
You have several options here. Setting a constant width may be one of them. You could also try display: block, which will make the buttons fill the entire width of their parent node.
Define some standard "width" for your buttons like,:
.buttonStyle {
margin-bottom: 10px;
border: none;
cursor: pointer;
font-size: 20px;
border-radius: 5px;
width:300px;
}
I have created a fiddle too to refer: http://jsfiddle.net/aasthatuteja/vChFX/
Hope this helps!
I'm applying a css class for the following asp.net custom control which renders in browser something like this:
<div class="box search_mlo">
<div class="gray_box">
<div class="blue_box">
<div>
<input id="Search_srcText" class="btn" type="text" onblur="return objSearchWidgetLibrary.searchLostFocus(ECMSSearchTextBox2_srcText)" onfocus="return objSearchWidgetLibrary.clearText2(ECMSSearchTextBox2_srcText)" onkeypress="return objSearchWidgetLibrary.fnTrapKD2('ECMSSearchTextBox2_srchAnchor1',event)" name="ECMSSearchTextBox2$srcText">
</input>
<a id="Search_srchAnchor1" class="btn" onclick="return objSearchWidgetLibrary.onsearchclick1('ECMSSearchTextBox2_srcText','ECMSSearchTextBox2_srchAnchor1')" href="../System/SearchResults.aspx?k=">
<span>Search</span>
</a>
</div>
</div>
</div>
</div>
The CSS class is:
.blue_box div a.btn
{
background: url("/publish/images/btn_search.jpg") no-repeat;
height: 36px;
width: 86px;
}
.blue_box div input.btn
{
background: url("/publish/images/bg_search.jpg") no-repeat scroll 9px 6px #FFFFFF;
border: 1px solid #0064AD;
color: #BFBFBF;
float: left;
font-size: 1.3em;
font-style: italic;
font-weight: bold;
height: 21px;
margin-right: 4px;
margin-top: 2px;
padding: 5px;
width: 328px;
}
so it looks something like search box and button to submit. This control is used by other sites so, for some sites we require only hyperlink search button and in some we replace image. But in this case I'm trying to replace image but I'm getting only half of the image something like below..
http://i.stack.imgur.com/Dfaqn.jpg
You can see a search text coming inside that image.
The prototype is something like this and the first button should match with this:
http://i.stack.imgur.com/QpRmg.jpg
I cannot remove that span tag present inside anchor tag since in other sites its working fine and removing that would create problem in them.
can any one help with feasible solution where I can get the entire image.?
Thanks in advance.
#Sayed; a tag is an inline element & inline elements didn't take height, width, vertical margin & padding. So; give display:block in your css for a tag like this:
.blue_box div a.btn
{
background: url("/publish/images/btn_search.jpg") no-repeat;
height: 36px;
width: 86px;
display:block
}
Hi all !
I want to create a small round static percent indicator in CSS but I can't find the solution.
The squared indicator at left is ok, but so ugly, I want it round !
I have tried with rounded corner (cf indicators at the right of the screenshot), and I wonder if there is possibility to add a rounded mask to hide the corners (cf. css3 mask : http://webkit.org/blog/181/css-masks/), but it seems like it's only for img...
The solution can works only on webkit browsers, because it's for a mobile webapp.
Here is my code to create the (ugly) indicator in the image above :
<div class="meter-wrap">
<div class="meter-value" style="background-color: #489d41; width: 70%;">
<div class="meter-text"> 70 % </div>
</div>
</div>
And the css :
.meter-wrap{
position: relative;
}
.meter-value {
background-color: #489d41;
}
.meter-wrap, .meter-value, .meter-text {
width: 30px; height: 30px;
/* Attempt to round the corner : (indicators at the right of the screenshot)
-webkit-border-radius : 15px;*/
}
.meter-wrap, .meter-value {
background: #bdbdbd top left no-repeat;
}
.meter-text {
position: absolute;
top:0; left:0;
padding-top: 2px;
color: #000;
text-align: center;
width: 100%;
font-size: 40%;
text-shadow: #fffeff 1px 1px 0;
}
Add a wrapper around your .meter-value class, set its overflow to hidden and then set the width of that layer to get the desired effect. The rounded corners on the .meter-value class should remain intact and give you a nice fluid progress indicator.
You will have to move the .meter-text div outside of the wrapper to ensure it's visible throughout the transition, so your html would like something like:
<div class="meter-wrap">
<div class="meter-text"> 70 % </div>
<div class="meter-value-wrapper" style="width:70%;">
<div class="meter-value" style="background-color: #489d41;">
</div>
</div>
And the class for .meter-value-wrapper might look like:
.meter-value-wrapper {
overflow: hidden;
width: 30px;
height: 30px;
}