I've got this bit of HTML:
<div id="content">
<h1 id="prompt">What's on your mind?</h1>
<form action="post.php" method="POST" id="message-form">
<textarea placeholder="Type in anything you want to share. Anything at all."></textarea>
<p>Feel free to type up to <span id="character-count">2000 characters</span>, or to use Markdown formatting.</p>
<input type="submit" class="submit button" value="Share" />
<br class="clearfix" />
</form>
</div>
and this CSS:
/* CSS Reset
-------------------------------------------*/
* {
margin: 0;
padding: 0;
}
.clearfix {
clear: both;
}
/* UI Elements
-------------------------------------------*/
.button {
background-color: #ccc;
background-image: -webkit-linear-gradient(white, #ccc);
background-image: -moz-linear-gradient(white, #ccc);
background-image: -ms-linear-gradient(white, #ccc);
background-image: -o-linear-gradient(white, #ccc);
background-image: linear-gradient(white, #ccc);
border: 1px solid #999;
border-radius: 10px;
color: #333;
cursor: pointer;
font-family: Arial, Helvetica, Sans-serif;
font-size: 13px;
outline: none;
padding: 3px 8px;
text-decoration: none;
}
.button:hover {
border-color: #666;
}
.button:active {
background-color: #bbb;
background-image: -webkit-linear-gradient(#ccc, white);
background-image: -moz-linear-gradient(#ccc, white);
background-image: -ms-linear-gradient(#ccc, white);
background-image: -o-linear-gradient(#ccc, white);
background-image: linear-gradient(#ccc, white);
}
/* Content
-------------------------------------------*/
#content {
margin: 10px;
}
/* Prompt
-------------------------------------------*/
#prompt {
color: #888;
font-weight: normal;
}
/* Message Box
-------------------------------------------*/
#message-form {
width: 600px;
}
#message-form textarea {
border: 1px solid #ccc;
border-radius: 6px;
display: block;
font-family: Georgia, Times New Roman, Times, Serif;
font-size: 16px;
min-height: 100px;
outline: none;
padding: 5px;
resize: vertical;
width: 100%;
-webkit-transition: border-color 0.25s ease-in-out;
-moz-transition: border-color 0.25s ease-in-out;
-ms-transition: border-color 0.25s ease-in-out;
-o-transition: border-color 0.25s ease-in-out;
transition: border-color 0.25s ease-in-out;
}
#message-form textarea:hover {
border-color: #666;
}
#message-form textarea:focus {
border-color: #3bf;
box-shadow: 0 0 5px #3bf;
}
#message-form p {
color: #666;
float: left;
font-size: 13px;
margin: 3px;
}
#message-form .submit {
float: right;
margin-right: 0;
}
What I'm trying to accomplish is to float an element rightwards within a particular amount of space. This works, but there's about 10 pixels' space to the right of the button that don't appear to exist! It's not padding from the parent element, nor margin on the button as far as I can see... so where is it coming from? Below is an image of the problem, and the full code can be found at https://github.com/minitech/MiniTicket. Here's a demo on jsFiddle, too.
Sorry for the overload of code, but I can't seem to reproduce the problem in a simple way.
Keep in mind that setting width: 100% and any amount of horizontal padding will cause your element to have a width beyond 100% (unless it's an input element, in which padding is applied inside of the element).
In your case, your textarea width is 610px. The submit button is properly floated to the far right of your 600px width container.
See: http://jsfiddle.net/Wexcode/KX7wd/1/
Replacement for padding in textarea: http://jsfiddle.net/Wexcode/KX7wd/2/
Related
I need to set css of button like this website, where you can see the Read more button with Dark color and half shadow
Please see the following image:
I tried below code, but I failed:
.rmbutton {
color: #ffffff !important;
background: #504d62 !important;
position: relative;
overflow: hidden;
padding: 13px 35px;
text-transform: uppercase;
display: inline-block;
font-size: 14px;
transition-property: background;
transition-duration: 0.3s;
transition-timing-function: ease;
transition-delay: 0s;
text-align: center;
font-weight: bold;
}
Thanks in advance!
Simple background, You should fiddle with the values to your liking.
button {
color: white;
padding: 40px 80px;
background: linear-gradient(100deg, red 25%, blue 26%);
}
<button>Don't click me</button>
I have some code here that creates an animated search bar:
<html>
<head>
<style>
input[type=text] {
width: 130px;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
font-size: 16px;
background-color: white;
background-image: url('searchicon.png');
background-position: 10px 10px;
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;
}
input[type=text]:focus {
width: 100%;
}
</style>
</head>
<body>
<form>
<input type="text" name="search" placeholder="Search..">
</form>
</body>
</html>
Whenever somebody clicks on it, the search bar expands and lets the user type the keyword(s). How would I make it so that when the user clicks on the search bar, it waits (e.g 1 secs) for the search bar to expand and then redirects to a URL. Do I change the input[type=text] to input[type=code] and do the same with input[type=text]:focus???? Please don't give too complicated answers and I am just a beginner. I looked up most directions to insert the code but my website does not support the site.com/?search=keywords. Please help!!
Thanks,
- Will
Maybe with JS :
<form>
<input type="text" name="search" placeholder="Search.." onClick="redirect()">
</form>
And :
<script>
function redirect() {
setTimeout(function(){
window.location.replace("http://stackoverflow.com");
}, 1000);
}
</script>
You can use the css propert for transition, "transition-delay" here is the code example. Here is a jsfiddle
input[type=text] {
width: 130px;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
font-size: 16px;
background-color: white;
background-image: url('searchicon.png');
background-position: 10px 10px;
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;
-webkit-transition-delay: 2s; /* Safari */
transition-delay: 2s;
}
input[type=text]:focus {
width: 100%;
}
My box is expanding to the right, how can I make it expand to the left?
input[type=text] {
width: 130px;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
font-size: 16px;
background-color: white;
background-image: url('searchicon.png');
background-position: 10px 10px;
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;
}
input[type=text]:focus {
width: 100%;
}
<form>
<input type="text" name="search" placeholder="Search..">
</form>
Just align it to the right of its container element. Either change the display attribute to block and set the right and left margins to 0 and auto, or keep it as an inline element and apply text-align: right to the container block.
input[type=text] {
display:block;
margin: 0 0 0 auto;
width: 130px;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
font-size: 16px;
background-color: white;
background-image: url('searchicon.png');
background-position: 10px 10px;
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;
}
input[type=text]:focus {
width: 100%;
}
<form>
<input type="text" name="search" placeholder="Search..">
</form>
I have a responsive website, on one of the pages I have 2 buttons, they are next to each other when the screen size is wide enough to fit both buttons, when the page is made smaller (i.e for a smartphone) then the second button (right) goes below the first. This works fine.
However when the buttons are one above the other they are positioned on the left, I would like to center them.
I have based it on this: http://jsfiddle.net/erenyener/puA72/2/
Here is a JS Fiddle: https://jsfiddle.net/kg2grant/
Here is the code:
HTML
<div class="button-wrapper">
<div class="fiftyLEFT" ><button type="submit" class="submit" value="submit" name="submit_button"><span>Search</span></button></div>
<div class="fiftyRIGHT"><button onclick="location.href='https://google.com';" class="submit" style="font-size: 22px; width: 500px" value="show" name="show_button">Google</button></div>
</div>
CSS
button.submit {
border: none;
background-image: linear-gradient(-180deg, #52A1DD 50%, #53A2DE 100%);
border-radius: 100px;
max-width: 90%;
margin-right: 5%;
padding: 8px 10px;
font-size: 26px;
color: #fff;
line-height: 30px;
cursor: pointer;
-webkit-transition: all .15s ease-in-out;
-moz-transition: all .15s ease-in-out;
-o-transition: all .15s ease-in-out;
transition: all .3s ease-in-out;
margin-top: 10px;
z-index: 1;
position: relative;
}
button.submit:hover {
color: #3193e9;
background: #fff;
}
button.submit {
width: calc(.5px + 50vw);
}
button.submit img: hover {
background-color: #C37500;
opacity:0.7 !important;
filter:alpha(opacity=70) !important;
}
.button-wrapper
{
width:100%;
padding-top:10px;
padding-bottom:10px;
display:inline-block;
border: 3px solid black
}
.button-wrapper > .fiftyLEFT
{
width:50%;
float:left;
min-width:50px
}
.button-wrapper > .fiftyRIGHT
{
min-width:400px;
width:50%;
float:left;
white-space: nowrap;
}
I have tried many things to like margin 0 auto and adding another container however had no luck! Thanks in advance for your help.
You can change the display to flex and achieve what you want by using #media query.
Forked jsFiddle with the behavior needed: https://jsfiddle.net/o1gpcLcr/
You will have to remove the float left property to do the margin auto.
.button-wrapper > .fiftyLEFT {
width: 50%;
/* float: left; */
min-width: 50px;
margin-left: auto;
margin-right: auto;
}
.button-wrapper > .fiftyRIGHT {
min-width: 400px;
width: 50%;
/* float: left; */
white-space: nowrap;
margin-left: auto;
margin-right: auto;
}
Then do the float left on larger screens with #media (min-width: 768px), or wherever you want it to break.
Using float makes margin auto behave strangely because the floated element have been removed from the regular flow of content. If you remove float: left from your last two CSS rules and declare margin: auto, it should work.
Alternatively, you can remove float: left, and then add
display: flex;
flex-flow: column;
justify-content: center;
align-items: center;
to your .button-wrapper rule. Using flexbox has the same effect as margin auto, but may make other changes and additions easier later in development.
To learn more about flexbox, check out https://flexbox.io for some great video tutorials.
You'll want to use CSS media queries, with more of a 'mobile-first' approach.
Make the buttons width: 100% by default and then use #media (min-width: 768px) {...} to change the width to 50%.
I've made some changes to your code:
button.submit {
border: none;
background-image: linear-gradient(-180deg, #52A1DD 50%, #53A2DE 100%);
border-radius: 100px;
padding: 8px 10px;
margin: 5px 0;
font-size: 26px;
color: #fff;
line-height: 30px;
cursor: pointer;
-webkit-transition: all .15s ease-in-out;
-moz-transition: all .15s ease-in-out;
-o-transition: all .15s ease-in-out;
transition: all .3s ease-in-out;
z-index: 1;
position: relative;
}
button.submit:hover {
color: #3193e9;
background: #fff;
}
button.submit img: hover {
background-color: #C37500;
opacity:0.7 !important;
filter:alpha(opacity=70) !important;
}
.button-wrapper {
width:100%;
padding: 10px 0;
display:inline-block;
border: 3px solid black
}
button {
width: 100%;
}
#media (min-width: 768px) {
button {
float: left;
width: 50%;
white-space: nowrap;
}
}
<div class="button-wrapper">
<div class="button" ><button type="submit" class="submit" value="submit" name="submit_button"><span>Search</span></button></div>
<div class="button"><button onclick="location.href='https://google.com';" class="submit" value="show" name="show_button">Google</button></div>
</div>
I am working on a project for my self. I made some img with a hover transition.
It works perfect in all browsers. But not on the ipad. Why? For some reasons i cant click on the the image because of the text. I dont know why that is. I got 2 examples:
Example 1:
http://jewelbeast.com/imghover/ If you test this 1 on the ipad and you click on the img. You will see that nothing happends. Because the text in Centered with vertical align and with text-align:.
Example 2
http://jewelbeast.com/imghover/test.html if you test this 1 on the ipad you can click on the right side of the image. Because there is no text on the right side.
CSS
div.hover-img-vertical-smallborder{
margin-top: 25px;
height: 400px;
width: 228px;
float: left;
display: block;
margin-left: 10px;
}
div.hover-img-vertical-smallborder section{
position: relative;
width: 217px;
height: 350px;
border: 5px solid white;
outline: 1px solid #c8c8c8;
float:left;
text-align: center;
-webkit-transition: all .3s;
-moz-transition: all .3s;
-ms-transition: all .3s;
-o-transition: all .3s;
transition: all .3s;
overflow: hidden;
background: #dfdfdf;
}
div.hover-img-vertical-smallborder section:hover{
height: 380px;
margin-top: -15px;
}
div.hover-img-vertical-smallborder section img{
position: absolute;
-webkit-transition: all .3s;
-moz-transition: all .3s;
-ms-transition: all .3s;
-o-transition: all .3s;
transition: all .3s;
}
div.hover-img-vertical-smallborder section .text{
position: absolute;
top: 0;
left: 0;
display: table;
height: 100%;
}
div.hover-img-vertical-smallborder section span{
width: 200px;
display: table-cell;
vertical-align: middle;
padding: 20px;
text-align: center;
color: black;
opacity: 0;
text-shadow: 1px 1px 0px rgba(255,255,255,0.3);
-webkit-transition: all .3s;
-moz-transition: all .3s;
-ms-transition: all .3s;
-o-transition: all .3s;
transition: all .3s;
}
div.hover-img-vertical-smallborder section:hover span{
opacity: 1;
}
div.hover-img-vertical-smallborder section:hover img{
opacity: 0.5;
}
div.hover-img-vertical-smallborder section span h1{
width: 100%;
text-align: center;
font-size: 18px;
font-family: Verdana, sans-serif;
font-weight: bold;
line-height: 25px;
margin-bottom: 3px;
}
div.hover-img-vertical-smallborder section span p{
width: 100%;
text-align: center;
font-size: 10px;
font-family: Verdana, sans-serif;
font-weight: bold;
margin-bottom: 10px;
}
div.hover-img-vertical-smallborder section span a.button{
display: table;
margin: 0px auto;
text-align: center;
color: white;
text-shadow: none !important;
text-decoration: none;
font-size: 10px;
font-family: Verdana, sans-serif;
font-weight: bold;
padding: 9px 10px 11px 10px;
border: 1px solid #616161;
outline: 1px solid #000000;
background: #494949; /* Old browsers */
background: -moz-linear-gradient(top, #494949 1%, #3a3a3a 94%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#494949), color-stop(94%,#3a3a3a)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #494949 1%,#3a3a3a 94%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #494949 1%,#3a3a3a 94%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #494949 1%,#3a3a3a 94%); /* IE10+ */
background: linear-gradient(to bottom, #494949 1%,#3a3a3a 94%); /* W3C */
}
div.hover-img-vertical-smallborder section span a.entire{
width: 100%;
position: absolute;
top: 0px;
left: 0px;
height: 100%;
}
HTML
<div class="hover-img-vertical-smallborder">
<section class="bg-black"> <!-- bg-black is a black background on hover normal is grey -->
<img src="img/img_5.jpg" style="left: -50%;"/>
<div class="text">
<span>
<h1>This is a title</h1>
</span>
</div>
</section>
</div>
I hope somebody can figure this out.
Thanks.
There is no hover event fired on a touch device. You need to use either one of these events in JS:
touchstart
touchmove
touchend
touchcancel