HTML: Can't delete small 5px gap between two buttons - html

I got a small gap between two buttons and I can't deal with it, tried to look in browser terminal, but that didn't helped.
Here are the buttons:
<div class="secondTableVRow">
<input type="submit" name="submit" value="Submit" id="submit" onMouseOver="onSubmitHover()" onMouseOut="submitFadeOut()" onclick="submitForm()"/>
<input type="button" name="extend" value="Advanced" id="extend" onMouseOver="noteFade('extendNote')" onMouseOut="noteFadeOut('extendNote')" onClick="advancedOptions()" />
</div>
CSS:
.secondTableVRow{
width:318px;
background-color:green;
display:inline-block;
}
#submit{
cursor:pointer;
display:inline-block;
font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
width:156px;
height:35px;
outline:none;
border:none;
background-color:#DDDDDD;
-webkit-transition: background-color 0.4s linear 0s;
-moz-transition: background-color 0.4s linear 0s;
-o-transition: background-color 0.4s linear 0s;
transition: background-color 0.4s linear 0s;
}
Both buttons have same CSS, I know I should use class for that and I will, just want to fix this problem first. Live example of buttons: http://www.diligencehelps.com/php_includes/register_form.php
There seems to be a small gap after EVERY element in the form, why is that happening?If any more code needed just ask.

Try this:
<div class="secondTableVRow">
<input type="submit" name="submit" value="Submit" id="submit" onMouseOver="onSubmitHover()" onMouseOut="submitFadeOut()" onclick="submitForm()"/><!--
--><input type="button" name="extend" value="Advanced" id="extend" onMouseOver="noteFade('extendNote')" onMouseOut="noteFadeOut('extendNote')" onClick="advancedOptions()" />
</div>
HTML can be very picky about the whitespaces.
For more background information, check this out: http://css-tricks.com/fighting-the-space-between-inline-block-elements/

Add this:
.secondTableVRow:last-of-type {
font-size: 0;
}
#submit, #extend {
width: 159px;
}
The space is due to whitespace - HTML interprets linebreaks as whitespace. font-size: 0 takes care of that, but leaves some extra space on the right as #submit and #extend don't quite fill their parent .secondTableVRow container. You could also use width: 50% instead of 159px.
The :last-of-type is to avoid the font-size: 0 from being applied to the .secondTableVRow earlier in the markup, but you could just give that last one an ID (or additional class like .final instead and select it that way, e.g. .secondTableVRow.final { font-size: 0; }.
edit: as Hauke mentioned in the comments, this may be problematic in certain older browers. It also will not work with relative font sizing (e.g. ems or %) because the font size will cascade to descendant elements. You could instead just add float: left to both buttons and overflow: hidden to their container, or another clearfix method.

You could specify them as 50% width, as block elements (instead of inline-block, as this is more supported on older browsers anyway), and float them both left. Just be sure to place a after, so your formatting isn't botched.

Related

Animate div size transition with unknown sizes

I would like to animate the transition of a div's size (signupForm) whose content changes dynamically.
The size of the container div in each step is unknown.
I would prefer to do this in CSS.
I'm using Vue.js to swap out the forms.
<div class="signupForm">
<component id="currentView">
<FormOne></FormOne>
<FormTwo></FormTwo>
<FormThree></FormThree>
<FormFour></FormFour>
<FormFive></FormFive>
</component>
</div>
#signupForm never leaves, but FormOne gets swapped for FormTwo, etc.
I have added the following:
.signupForm {
max-height:inherit;
display:inline-block;
transition: max-height 0.3s ease-in-out;
}
But the transition property didn't help much. Any ideas?
I am not sure max-height has transform possibility, Maybe this helps:
.signupForm {
max-height:inherit;
display:inline-block;
transition: height 0.3s ease-in-out;
}
I think that the problem is with max-height: inherit;
Try to use some big value in px (5000px for example). The value that you think, you will never reach.

apply styles to empty input/textarea only

I was wondering if it is possible to apply styles to an empty textarea only. As a minimal example, I'd like a comments box that expands when the user clicks on it (:focus), but stays expanded when the user entered text, but re-collapse when the box is empty.
I have already tried :empty, but that doesn't work for inputs/textareas (only DOM elements).
#comments {
width: 150px;
height: 30px;
font-family: sans-serif;
border-radius: 5px;
outline:none;
-webkit-transition: all 1s;
-moz-transition: all 1s;
transition: all 1s;
}
#comments:not(:empty),
#comments:focus {
width: 250px;
height:100px;
border-radius: 10px;
}
<textarea type="text" id="comments" placeholder="Place a comment"></textarea>
Is there any way to make the input stay big when the user entered something in it?
From what I can see, :empty is still a working draft and may not be supported by the specific browser you are using.
A quick JavaScript solution would be to add/remove an HTML class based upon whether or not the textarea has a value.
.empty{/*styles go here*/}
And your JavaScript:
textareaElement.addEventListener('input',function(){
if(this.value && this.classList.contains("empty")) this.classList.remove("empty");
else this.classList.add("empty");
},false);
More info about Element.classList can be found on MDN.

Make anchor text copyable

I have a question regarding links and divs. I want the whole div to be clickable and in the same time the text should be copyable, so that the google bots for example can read them as text.
Anybody got any ideas?
my code looks like this :
<div id="menubutton1"><br>
SOTNING</div>
#menubutton1{ width:149px; height:77px; float:left;margin-left:290px; text-align:center;
-webkit-transition: background-color 1s ease-out;
-moz-transition: background-color 1s ease-out;
-o-transition: background-color 2s ease-out;
transition: background-color 2s ease-out;
}
#menubutton1:hover{
background-color: #F93;
cursor: pointer;
}
Your best bet is to create an anchor element, set that to display:block and position:absolute. See below:
<div id="menubutton1">
<p>You text which you want read by search engine bots.</p>
</div>
Add the following style
<style>
#menubutton1{
position:relative;
}
.fill{
position:absolute;
display:block;
top:0;
left:0;
right:0;
bottom:0;
width:100%;
height:100%;
}
</style>
See fiddle.
The text won't be selectable directly from the DIV as the anchor block is floating over the top, but if selecting the page or from outside the DIV then the text can still be selected.
There's no evidence showing this will affect search bots reading the content as the content is still visible.
Alternatively you will need to use a JavaScript function to run on the click event and go to a specified link. This will however cause a problem for a search bot as they don't knowingly read/follow JavaScript. If you do choose the JS route I'd suggest having the link available on the page elsewhere too to ensure it is followed.

Setting css values through html?

I am using php, html, and css to create a caption that displays the title first then sliding even more to reveal excerpt on hover.
Sample structure of basic post setup (simplified for clarity):
<div class="post-container">
<img src="postThumbnail.jpg" />
<span class="post-caption-container">
title
this is the excerpt
</span>
</div>
CSS file
.post-container{
position: absolute;
height: 200px;
width: 300px;
overflow: hidden;
}
.post-caption-container{
width: 300px;
height: 80px;
top: -45px;
}
.post-container:hover .post-caption-container{
top: 0px;
-webkit-transition: all 300ms ease-out;
-moz-transition: all 300ms ease-out;
-o-transition: all 300ms ease-out;
-ms-transition: all 300ms ease-out;
transition: all 300ms ease-out;
}
Inline HTML to override styling
<div id="post-container" style="height: 140px;">
<img src="postThumbnail.jpg" />
<span class="post-caption-container" style="height: 50px; top: -25px; ">
title
this is the excerpt
</span>
</div>
The portion where "style = top: -25px;" is causing problems.
My best guess is that the inline html styling "style= top: -25px;" is overriding values in both ".post-caption-container" and ".post-container:hover .post-caption-container", which is not what I want.
I need ".post-container:hover .post-caption-container" value to remain "top: 0px;".
I've spent about a week trying to resolve this issue, but I'm stuck! I don't know if this is impossible to achieve?
Any help would be appreciated. If this problem is impossible, perhaps an alternative method to achieve the same result, would love some different ideas as well! oi vey, thanks so much!
Positioning values like top: XXpx etc. don't work unless the element they are applied to also has a position set, such as position: relative, so perhaps try adding that in. I don't quite understand the example you are working with, but that might be all you need to get it working.
PS: Welcome to Stack Overflow. :-)
EDIT: In response to comments below, I now understand that the problem relates to an inline style overriding stylesheet declarations, and yes, inline styles carry more weight that stylesheet rules in the laws of the cascade.
However, there is one way to override the inline style, using !important:
.post-container:hover .post-caption-container{
top: 0px !important;
}
So, you place !important after the rule but before the semicolon. (Note also the period . before .post-caption-container above. You left it out, but without it the declaration won't work anyway.

Text will not wrap to element when all anchors

http://jsfiddle.net/awWmY/
For the life of me I can't solve this simple one. Why wont the text wrap to #bigEnough?
html{background:black;}
#bigEnough {
width: 500px;
text-wrap: normal;
}
#bigEnough a {
-moz-transition: none !important;
-webkit-transition: none !important;
-o-transition: none !important;
-ms-transition: none !important;
-moz-transition: none;
-webkit-transition: none;
-o-transition: none;
-ms-transition: none;
transition: none;
}
#tagCloud {
height: 500px;
width: 500px;
float: right;
margin: -45px 0;
}
The simplest solution I could find (with full cross-browser implementation) is to use display: inline-block on the a elements: JS Fiddle demo.
Note that I've also increased the width of the page, to show that the words will also occupy the same lines where space is available.
Adding word-break: break-word; to your #bigEnough CSS will force the words to wrap but not at break points between the several anchor tags. I don't know if that's the behavior you were trying to achieve, but here's a demo: jsFiddle.
Hope that helped in any manner!
Because word wrapping depends on there being a space between words.
The others are right, you need to use spaces for words to wrap. If you want to avoid doing that, however, I've had success with:
Hyphenator
Hyphenator is a JavaScript solution that automatically wraps long words so that they fit in their parent container and inserts hyphens where the wrap occurs.
As others have noted, you should really have some whitespace between the a elements. But if you cannot change the markup, you can inject no-break spaces U+200B (which are line-breaking opportunities) with generated content:
#bigEnough a:after { content: "\200B"; }
Usual CSS Caveats apply.
Not sure sure what you are trying to achieve but you can try this if this is what you need
#bigEnough a {
display:inline-block;
/* rest of your styles*/
}
DEMO.