Horizontally stretched button - html

I've task to create button with rounded corners that will stretch horizontally to container (now containers is only div's).
It should work in IE8 and higher.
Can you please advise is appropriate solution that I provide or there is better exist?
My solution:
.button-streched {
cursor: pointer;
width: 100%;
clear: both;
background-position: 0px 0px;
}
div.button-show-more div{
background-repeat: no-repeat;
height: 34px;
padding: 0;
}
.button-streched .left {
float: left;
background-image: url(/Images/buttton-left.png);
width: 6px;
height: 34px;
}
.button-streched .right {
float: right;
background-image: url(/Images/buttton-right.png);
width: 6px;
height: 34px;
}
.button-streched .middle {
background-image: url(/Images/buttton-middle.png);
background-repeat: repeat-x;
background-color: lightgreen;
margin: 0px 6px;
text-align: center;
}
.button-streched span{
vertical-align: middle;
line-height: 34px;
}
div.button-streched:hover .left,
div.button-streched:hover .middle,
div.button-streched:hover .right {
background-position: 0 100%;
cursor: pointer;
}
and HTML:
<div id="btnButton1" class="button-streched" style="">
<div class="left"></div>
<div style="width: 100%;">
<div class="right"></div>
<div class="middle">
<span>Do Some Action</span>
</div>
</div>
</div>
Shorten version, just to demonstrate that it works:
http://jsfiddle.net/xMKhZ/

You can make use of CSS3 PIE for rendering several of the most useful CSS3 decoration features.

Replace your CSS with this one.
.button-streched {
cursor: pointer;
width: 100%;
clear: both;
background-position: 0px 0px;
}
div.button-show-more div{
background-repeat: no-repeat;
height: 34px;
padding: 0;
}
.button-streched .left {
float: left;
background-image: url(/Images/buttton-left.png);
width: 6px;
height: 34px;
}
.button-streched .right {
float: right;
background-image: url(/Images/buttton-right.png);
width: 6px;
height: 34px;
}
.button-streched .middle {
background-image: url(/Images/buttton-middle.png);
background-repeat: repeat-x;
background-color: lightgreen;
margin: 0px 6px;
text-align: center;
border-radius:10px;
}
.button-streched span{
vertical-align: middle;
line-height: 34px;
}
div.button-streched:hover .left,
div.button-streched:hover .middle,
div.button-streched:hover .right {
background-position: 0 100%;
cursor: pointer;
}

Related

align image to the left corner of the div vertically center

I am trying to achieve this [enter image description here][1]
[1]: (https://i.stack.imgur.com/4ZOBB.jpg), i have managed to make it work on pc but its not looking same on mobile. Here code i have managed to create so far. box height should be less than of image. i have tried display:table but its also not working properly. please help. thank you.
body {
font-family: 'Abel', sans-serif;
}
.content-wrapper {
min-height: 100vh;
background-color: #d9dde2;
}
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.3);
background: #fff;
}
::-webkit-scrollbar-thumb {
background: #f89b0f;
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.5);
}
::-webkit-scrollbar-thumb:window-inactive {
background: #f89b0f;
}
a {
color: #f39c12;
}
.content-header>.breadcrumb {
background: #f89b0f;
right: 25px;
border-radius: 25px;
color: #fff;
padding: 10px;
}
.modal-dialog {
z-index: 1200;
}
.solid-header-default {
background: #f0f0f0;
}
.solid-header-success {
background: #00a65a;
}
h2 {
font-size: 18px;
}
.gcircle {
height: 50px;
width: 50px;
background-color: #938005;
border-radius: 50%;
display: inline-block;
}
.circle-block {
text-align: center;
vertical-align: middle;
}
.circle {
background: #938005;
border-radius: 50%;
color: black;
display: inline-block;
height: 50px;
font-weight: bold;
font-size: 1.2em;
width: 50px;
margin: 0 auto;
}
.circle span {
display: table-cell;
vertical-align: middle;
height: 50px;
width: 50px;
text-align: center;
padding: 0 15px;
}
.c-chart {
display: inline-block;
vertical-align: top;
padding: 5px;
}
.brandlogo-image {
float: left;
line-height: .8;
margin-left: .8rem;
margin-right: .5rem;
margin-top: -6px;
max-height: 34px;
width: auto;
}
.dashboard-box {
max-width: 400px;
min-width: 150px;
background-color: #C43805 !important;
border-radius: 15px;
margin-left: 60px;
min-height: 50px;
max-height: 80px;
display: flex;
align-items: center;
}
.dash-img {
vertical-align: middle;
}
.inner {
display: inline-block;
}
<div class="dashboard-box" >
<img src="http://phiz.live/portal/assets/theme/img/c1.png" alt="Phiz.Live" style="margin-left:-70px;width:35%;" class="dash-img">
</div>
You can use Flexbox. what ever you want to center, you it inside .center1 and .center2 div. For more information. https://www.w3schools.com/css/css_align.asp
.dashboard-box {
max-width: 400px;
min-width: 150px;
background-color: #C43805 !important;
border-radius: 15px;
margin-left: 60px;
min-height: 50px;
max-height: 80px;
display: flex;
align-items: center;
}
.dash-img {
vertical-align: middle;
}
.center1 {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
width: 500px;
background: steelblue;
}
.center2 {
width: 100%;
}
<div class="center1" >
<div class="center2">
<div class="dashboard-box" >
<img src="http://phiz.live/portal/assets/theme/img/c1.png" alt="Phiz.Live" style="margin-left:-70px;width:35%;" class="dash-img">
</div>
</div>
</div>
Think I got it working the way you want here: JSfiddle link, but I changed margin-left to -30px for the image and margin-left: 30px;for the .dashboard-box. Perhaps it can help you.
HTML
<div class="wrapper">
<div class="dashboard-box" >
<img src="http://phiz.live/portal/assets/theme/img/c1.png" alt="Phiz.Live" style="margin-left:-30px;width:35%;" class="dash-img">
</div>
</div>
CSS
.wrapper {
height: 20vh;
display: flex;
align-items: center;
}
.dashboard-box {
max-width: 400px;
min-width: 150px;
background-color: #C43805 !important;
border-radius: 15px;
margin-left: 30px;
min-height: 50px;
max-height: 80px;
display: flex;
align-items: center;
}

Can't set up image in the div

I'd like to have a div, which contains:
Text on the top
Some image below it
How I may make it? Here's what I did so far
.container {
text-align: center;
display: inline-block;
width: 100%;
height: 180pt;
border: 1px solid red;
}
.text {
width: 12%;
height: 180px;
text-align: left;
background-color: yellow;
margin: 20px;
}
.text p {
font-size: 20px;
margin-left: 0 auto;
margin-right: 0 auto;
margin-top: 15px;
text-align: center;
}
.image {
width: 100%;
height: 100%;
display: inline-block;
background-image: url("url_to_img");
background-size: cover;
background-repeat: no-repeat;
}
<div class="container">
<div class="text">
<p>Lorem</p>
<div class="image"></div>
</div>
</div>
For now, the <p> is working just fine, but I have struggle with the image it's sticking out the borders of container div.
It's because you gave the test class too much margin. try not to mix up size units if possible.
add overflow:hidden; on .text class
.container {
text-align: center;
display: inline-block;
width: 100%;
height: 180pt;
border: 1px solid red;
}
.text {
width: 19%;
height: 180px;
text-align: left;
background-color: yellow;
margin: 10px;
overflow:hidden;
}
.text p {
font-size: 20px;
margin-left: 0 auto;
margin-right: 0 auto;
margin-top: 1px;
text-align: center;
}
.image {
width: 100%;
height: 100%;
display: inline-block;
background-image: url("https://avatars.mds.yandex.net/get-pdb/1380368/3e559dd1-32ad-4226-aac5-77ed3782a962/s1200");
background-size: cover;
background-position:center;
background-repeat: no-repeat;
}
<div class="container">
<div class="text">
<p>Lorem</p>
<div class="image"></div>
</div>
</div>
Here is a fiddle to get you started with, I didn't change much code because I didn't new your requirements Just did workaround around same code
https://jsfiddle.net/junaidmasoodi/vctwu2g5/11/
.text {
width: 100%;
height: 180px;
text-align: left;
background-color: yellow;
margin: 20px;
}
.text p {
font-size: 20px;
margin-left: 0 auto;
margin-right: 0 auto;
margin-top: 15px;
text-align: center;
}
.image {
width: 100%;
height: 100%;
display: block;
background-image: url("https://309w5s255371fs4df2vftgbl-wpengine.netdna-ssl.com/wp-content/uploads/2017/09/placeholder.jpg");
background-size: cover;
background-repeat: no-repeat;
}
for your .image block you could try background-size: contain; instead of cover

One div with input and other div inside

how can I get the input aligned with the div #submitKeyword ?
FIDDLE
HTML:
<div class="searchKeywords">
<input id="inputKeyword" type="text" name="keywords" placeholder="What are you looking for?">
<div id="submitKeyword"></div>
</div>
CSS:
.searchKeywords {
height: 100%;
width: 100%;
margin-top: 70px;
text-align: center;
}
.searchKeywords #inputKeyword {
display: inline-block;
height: 45px;
width: 150px;
border: 2px solid;
}
.searchKeywords #submitKeyword {
display: inline-block;
width: 115px;
height: 45px;
border: 1px solid #000;
background-image: url('/www/assets/newImages/gallery/Lupa.png');
background-repeat: no-repeat;
background-position: center;
}
Use vertical-align: middle;
.searchKeywords {
display: inline-block;
height: 100%;
width: 100%;
margin-top: 70px;
text-align: center;
vertical-align: middle;
}
.searchKeywords #inputKeyword {
height: 45px;
width: 150px;
border: 2px solid;
}
.searchKeywords #submitKeyword {
display: inline-block;
width: 115px;
height: 45px;
border: 1px solid #000;
background-image: url('/www/assets/newImages/gallery/Lupa.png');
background-repeat: no-repeat;
background-position: center;
vertical-align: middle;
}
Check this link http://jsfiddle.net/amoljawale/B45P5/1/
I suggest to go with display:table. Also use margin: auto instead of text-align:center to align your elements in the middle.
css
.searchKeywords {
height: 100%;
display: table;
margin: auto;
position: relative;
top: 70px;
}
.searchKeywords #inputKeyword {
display: table-cell;
height: 45px;
width: 150px;
border: 2px solid;
}
.searchKeywords #submitKeyword {
display: table-cell;
width: 115px;
height: 45px;
border: 1px solid #000;
background-image: url('/www/assets/newImages/gallery/Lupa.png');
background-repeat: no-repeat;
background-position: center;
}
fiddle

Why is there spacing below this image

For some reason, I can't figure out why there is like an 8px spacing below this image within a div. check it out:
If you look at the bottom of the image, there's about an 8px space, how can i get rid of it?
.side {
margin-top: 40px;
float: right;
}
.sidehead {
width: 260px;
height: 27px;
}
.sidecont {
background-color: #394d49;
width: 258px;
height: auto;
border: 1px solid #6b958b;
margin-top: -1px;
margin-bottom: 20px;
vertical-align: middle;
}
<!----HTML BELOW---->
<div class="sidecont">
<center><img src="images/rankings.jpg"></center>
</div>
Here's the entire code, if anyone needs it:
body {
background-image: url('images/bg.png');
background-color: #5a6a7a;
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center top;
}
.wrap {
width: 960px;
margin: auto;
}
.head {
width: 960px;
height: 60px;
margin-top: 33px;
}
.head img {
float: left;
}
.head .home img { background: url('images/home.jpg'); width: 116px; height: 60px; }
.head .register img { background: url('images/register.jpg'); width: 116px; height: 60px; }
.head .forum img { background: url('images/forum.jpg'); width: 116px; height: 60px; }
.head .banner img { background: url('images/banner.jpg'); width: 263px; height: 60px; }
.head .chat img { background: url('images/chat.jpg'); width: 116px; height: 60px; }
.head .downloads img { background: url('images/downloads.jpg'); width: 116px; height: 60px; }
.head .donate img { background: url('images/donate.jpg'); width: 117px; height: 60px; }
.head .home img:hover { background: url('images/homehover.jpg'); width: 116px; height: 60px; }
.head .register img:hover { background: url('images/registerhover.jpg'); width: 116px; height: 60px; }
.head .forum img:hover { background: url('images/forumhover.jpg'); width: 116px; height: 60px; }
.head .chat img:hover { background: url('images/chathover.jpg'); width: 116px; height: 60px; }
.head .downloads img:hover { background: url('images/downloadshover.jpg'); width: 116px; height: 60px; }
.head .donate img:hover { background: url('images/donatehover.jpg'); width: 117px; height: 60px; }
.logo {
background-image: url('images/logo.png');
width:250px;
height: 110px;
display:block;
position:absolute;
left:0;
right:0;
bottom:0;
margin: -85px auto;
z-index: 1;
}
.main {
margin-top: 40px;
float: left;
clear: both;
}
* {
margin: 0;
padding: 0;
}
.mainhead {
background-image: url('images/content.jpg');
height: 27px;
width: 680px;
}
.maincont {
background-color: #394d49;
width: 668px;
border: 1px solid #6b958b;
margin-top: -1px;
height: auto;
word-wrap: break-word;
padding: 5px;
}
.side {
margin-top: 40px;
float: right;
}
.sidehead {
width: 260px;
height: 27px;
}
.sidecont {
background-color: #394d49;
width: 258px;
height: auto;
border: 1px solid #6b958b;
margin-top: -1px;
margin-bottom: 20px;
vertical-align: middle;
}
.footer {
background-image: url('images/footer.jpg');
width: 960px;
height: 19px;
margin-top: 20px;
font-size: 11.6px;
font-family: 'MS Serif';
text-align: center;
color: #dfd591;
text-shadow: 0 1px 2px black;
line-height: 19px;
}
__
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="wrap">
<div style="position:relative;">
<div class="logo"></div>
</div>
<div class="head">
<div class="home"><img></div>
<div class="register"><img></div>
<div class="forum"><img></div>
<div class="banner"><img></div>
<div class="chat"><img></div>
<div class="downloads"><img></div>
<div class="donate"><img></div>
</div>
<div class="main">
<div class="mainhead"></div>
<div class="maincont">
</div>
</div>
<div class="side">
<div class="sidehead"><img src="images/servinfo.jpg"></div>
<div class="sidecont">asdf</div>
<div class="sidecont">
<center><img src="images/rankings.jpg"></center>
</div>
<div class="sidehead"><img src="images/partners.jpg"></div>
<div class="sidecont">
<center><img src="images/epvp.jpg"></center>
</div>
</div>
<div style="clear:both;"></div>
<div class="footer"></div>
</div>
</body>
An image is an inline element, which means that it is placed on the baseline of the text. There is space below the baseline in a text block, for characters with descenders like p and g. It's that space that creates the spacing below the image.
You can make the image a block element to avoid that space, and don't use the deprecated center tag, use margins to center the image:
HTML:
<div class="sidecont">
<img src="images/rankings.jpg">
</div>
Add to the CSS:
.sidecont img { display: block; margin: 0 auto; }
no tag center <!doctype html> html5
<div class="sidecont">
<img src="images/rankings.jpg">
</div>
.sidecont {
margin: 0 auto;
background-color: #394d49;
width: 258px;
height: auto;
border: 1px solid #6b958b;
}

CSS split bar graph with solid border radius

I'm trying to let a div container with a black background substitute as the border style for a bar graph that has a border radius. Here's the HTML/CSS:
HTML:
<div class="graph-outer">
<div class="inner-left-cap"></div>
<div class="inner-left-bar">40%</div>
<div class="inner-right-bar">60%</div>
<div class="inner-right-cap"></div>
</div>
CSS:
.graph-outer {
background-color: black;
height: 20px;
width: 300px;
border-radius: 10px;
padding: 1px;
}
.inner-left-cap {
background: orange;
width: 2%;
height: 100%;
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
float: left;
}
.inner-left-bar {
background: orange;
width: 38%;
height: 100%;
text-align: center;
float: left;
}
.inner-right-cap {
background: red;
width: 2%;
height: 100%;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
float: left;
}
.inner-right-bar {
background: red;
width: 58%;
height: 100%;
text-align: center;
float: left;
}
http://jsfiddle.net/2ZkDz/115/
The issue in which I am having is that the corners don't look as if they have any black border style whatsoever. What can I do?
Use this version with overflow:hidden and a explicit border on your outer controller and no padding.
.graph-outer {
background-color: black;
height: 20px;
width: 300px;
border:1px solid black;
border-radius: 10px;
overflow:hidden;
}
.inner-left-cap {
background: orange;
width: 2%;
height: 100%;
float: left;
}
.inner-left-bar {
background: orange;
width: 38%;
height: 100%;
text-align: center;
float: left;
}
.inner-right-cap {
background: red;
width: 2%;
height: 100%;
float: left;
}
.inner-right-bar {
background: red;
width: 58%;
height: 100%;
text-align: center;
float: left;
}
​
http://jsfiddle.net/2ZkDz/116/
I've updated your CSS, I changed the caps to 3% each and made the bars smaller. The bar on the inside was going over the caps.
.graph-outer {
background-color: black;
height: 20px;
width: 300px;
border-radius: 10px;
padding: 1px;
}
.inner-left-cap {
background: orange;
width: 3%;
height: 100%;
border-top-left-radius: 10px;
border-bottom-left-radius: 10px;
float: left;
}
.inner-left-bar {
background: orange;
width: 37%;
height: 100%;
text-align: center;
float: left;
}
.inner-right-cap {
background: red;
width: 3%;
height: 100%;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
float: left;
}
.inner-right-bar {
background: red;
width: 57%;
height: 100%;
text-align: center;
float: left;
}
​
http://jsfiddle.net/2ZkDz/119/
http://jsfiddle.net/2ZkDz/120/
border-radius: 10px;
padding: 2px;
That should do it! I just threw on a border-radius and bumped up the padding 1. There should be an easier way using the actual border property but im feeling lazy and this does it
a solution without the end-caps (that way the bar width matches the values)
demo jsfiddle
the graph-outer is 20px tall so the nested bars are 18px (20px - 2px (1px top/bottom padding)), set the border-radius on the bars to 9px each (half of the height so each corner is uniform and matches the parents curvature)
.inner-left-bar {
background: orange;
width: 40%;
height: 100%;
text-align: center;
float: left;
border-radius:9px 0 0 9px; /* add this */
}
.inner-right-bar {
background: red;
width: 60%;
height: 100%;
text-align: center;
float: left;
border-radius:0 9px 9px 0; /* and this */
}
/* and drop the end-caps */
​