I want to use prop line-height and height center vertically a text input in one div.
Below is the less code snippets:
div.header {
background-color: #6283E6;
height: 70px;
line-height: 70px;
min-width: 1220px;
input.search-input {
border: none;
border-radius: 16px;
background-color: #C9D4F6;
background-image:url('../assets/search.png');
background-repeat: no-repeat;
background-position: 14px, center;
height: 30px;
width: 353px;
padding-left: 49px;
}
}
But the actual effect in chrome is in below:
So why this happened.
Can you tell me?
Below is my Jsx code, Header has only one parent node and this node is the root node.
class Header extends React.Component {
render() {
return (
<div className={style.header}>
<input type="text" className={style['search-input']} />
</div>
);
}
}
I tested your code, and it seems fine to me:
div.header {background-color: #6283E6;
height: 70px;
line-height: 70px;
min-width: 1220px;
}
input.search-input {
border: none;
border-radius: 16px;
background-color: #C9D4F6;
background-image:url('../assets/search.png');
background-repeat: no-repeat;
background-position: 14px, center;
height: 30px;
width: 353px;
padding-left: 49px;
}
<div class="header">
<input type="text" class="search-input">
</div>
There must be something else wrong in code that you didn't show us.
Remember div and input have default margin and padding, so set margin and padding to 0 for both.
Alternatives:
Instead of fixing the height, you can use padding on the top and bottom.
You can use flex.
Related
I was trying to create a button using CSS. The html code looks like
<div class="content">
<img src="http://cdn4.iconfinder.com/data/icons/socialmediaicons_v120/48/google.png"/ width="20" height="20">
<span class="fon">Google</span>
</div>
And CSS is
.content {
width: 120px;
overflow: hidden;
color: #f5f5f5;
background: #2d3f51;
}
.content img {
margin: 5px;
float: left;
}
.fon{
position:relative;top:5px;
}
I'm getting output as expected, but I wanted to reduce repetitive html code and move them to CSS, so that I just need to write code similar to below code and should show same output :
<span class="mybutton">Google</span>
Here is my JSFiddle
http://jsfiddle.net/WW4N6/678/
html
<p class="mybutton">Google</p>
css
.mybutton {
background: #2d3f51;
color: #f5f5f5;
display: flex;
align-items: center;
height: 30px;
width: 100px;
padding: 0 5px;
}
.mybutton:before {
content: '';
background: url('http://cdn4.iconfinder.com/data/icons/socialmediaicons_v120/48/google.png');
background-size: cover;
width: 20px;
height: 20px;
display: inline-block
}
JSFiddle: http://jsfiddle.net/WW4N6/681/
css
.mybutton {
width: 90px;
height: 30px;
overflow: hidden;
color: #f5f5f5;
background: #2d3f51;
background-image: url(http://cdn4.iconfinder.com/data/icons/socialmediaicons_v120/48/google.png);
background-size: 20px, 20px;
background-repeat: no-repeat;
background-position: 5px;
padding-top: 10px;
padding-left: 30px;
}
jsFiddle link
http://jsfiddle.net/joshchurning/9sysby5f/
you could use css's background property for your button:
.mybutton {
....
background: url('http://cdn4.iconfinder.com/data/icons/socialmediaicons_v120/48/google.png') no-repeat center center #2d3f51
....
}
If you want to get rid of the HTML code (the width and length of img, I'm assuming), you could just put the width and height in your .content img CSS class
.content img {
margin: 5px;
float: left;
width: 20px;
height: 20px;
}
I am creating a table and I am having issues with a picture I am trying to add into one of the <td> fields. It's an icon I have and I want it to display for every record that shows up. The picture's actual size is 64px by 64px. I am trying to get it to be at 36x36, so I set my width and height to that, but it is not taking that and it cutting off the sides to it. Another issue with this table is that I have the index_announcements_wrap set to 100%, but when I try to add the <td>'s the width attribute, it messes up the picture even more, and when I add more than 40% to the message the table doesn't expand to the right.
I created a fiddle to show everything and make it easier for everyone to see what I am doing. I want the table's columns to be 100% of the container and for it to stretch the whole width under the red bar.
https://jsfiddle.net/9w5jsd06/
You need to account for the background size, currently it's set to cover so the image covers the space of the containers, instead use contain to display it AS IS and use no-repeat to avoid the image from repeating.
Change:
background-size: cover;
To:
background-size: contain;
background-repeat: no-repeat;
Here is how I would do it so it's also responsive:
.wrapper {
border: solid 1px #C0C0C0;
border-radius: 8px;
padding: 10px;
min-height: 80px;
text-align: center;
box-sizing: content-box;
}
header {
border: solid 1px #800000;
border-radius: 8px;
padding: 10px;
background: #800000;
color: white;
}
.warning_image {
width: 36px;
height: 36px;
}
.col-3 {
display: inline;
float: left;
width: 32%;
}
#media (max-width: 640px) {
.col-3 {
width: 100%;
display: block;
}
.wrapper {
min-height: 170px;
}
}
<div class="wrapper">
<header>
League Announcements:
</header>
<section>
<div class="col-3">
<img class="warning_image" src="http://png-2.findicons.com/files/icons/1609/ose_png/256/warning.png" alt="">
</div>
<div class="col-3">
<p>FROM: <?php echo date('Y-m-d'); ?></p>
</div>
<div class="col-3">
<p>Work for me!</p>
</div>
</section>
</div>
set display: block for your .index_announcement_pic class
fiddle here
.index_announcement_pic {
background: url("http://png-2.findicons.com/files/icons/1609/ose_png/256/warning.png") no-repeat;
width: 36px;
height: 36px;
background-size: contain;
background-position: center;
padding: 8px;
position: absolute;
replace this with your .index_announcement_pic in css it will work fine
if you want to display your picture 36*36 then you have to do like this
http://png-2.findicons.com/files/icons/1609/ose_png/256/warning.png
instead of
.index_announcement_pic {
background-image: url("http://png-2.findicons.com/files/icons/1609/ose_png/256/warning.png");
width: 36px;
height: 36px;
background-size: cover;
background-position: center;
padding: 8px;
/*position: absolute;*/
/*margin-right: 10%;
margin-left: 10%;*/
}
<td class="index_announcement_pic"></td>
do this
.index_announcement_pic {
width: 36px;
height: 36px;
padding: 8px;
}
<td >
<img src="http://png-2.findicons.com/files/icons/1609/ose_png/256/warning.png" class="index_announcement_pic">
</td>
when i change resolution of my display text on my top bar is changing
Can somebody help me to fix it?
Normaly:
http://funedit.com/imgedit/soubory/small_10348459921396544905.jpg?x
With changed resolution, or with smaller borowser window:
http://funedit.com/imgedit/soubory/small_19550755301396544822.jpg
My Html:
<body>
<div class="top-panel">
<div id="center"> <a class="top-button" href="#"></a>
<span class="text">Prave hraje <b>5000</b> hracov na <b>150</b> serveroch!</span>
<span class="panel">Registruj sa zdarma nebo</span>
<input type="text">
<input type="text">
<input type="image" id="login-button" src="images/login_button.png" alt="Submit">
<div class="warningimg"></div><div class="warning"> NIGHT CUP 2014 - Sledujte priamy prenos! </div>
<div class="main">
<div class="logobg">
<a class="logo" href="#"></a>
<input class="searchinput" type="text">
<input class="searchsubmit" type="image">
<div class="news"></div>
</div>
</div>
</div>
</div>
</body>
My CSS:
body {
background-image:url('images/background.png');
background-repeat: no-repeat;
background-color:#cccccc;
background-size 100%;
margin: 0 auto;
font-family: Arial;
font-size: 13px;
position: relative;
background-position: 50% 0;
background-attachment: fixed;
}
#center {
width: 1030px;
margin: 0 auto;
/*display: inline-block; */
}
.top-panel {
background-image: url("images/top_panel.png");
background-repeat: repeat-x;
background-position: center;
height: 43px;
padding-top:5px;
display: block;
}
a.top-button {
background-image: url("images/top_button.png");
height: 37px;
width: 141px;
background-repeat: no-repeat;
display: inline-block;
margin-left: 20px;
}
.text {
color: #9c9c9c;
padding: 0px 10px;
}
.panel {
color: #6ab1ed;
padding: 0px 390px;
}
input{
vertical-align:top;
display: inline-block;
height: 21px;
width: 97px;
line-height: 25px;
text-align: center;
position: relative; left: 550px; top: 4px;
}
span{
position: absolute;
display: inline-block;
height: 35px;
line-height: 35px;
text-align: center;
}
span b{
font-weight:bold;
}
#login-button{
/*background-image: url("images/login_button.png"); uz je to v HTML*/
height: 27px;
width: 81px;
line-height: 27px;
display: inline-block;
position: relative; left: 550px; top: 4px;
}
If somebody want to see the site LIVE its here: funedit.com/andurit/new/
Thank you all for reading this:)
a quick fix would be:
.panel {
color: #6AB1ED;
line-height: 1;
padding: 0 390px;
width: 150px;
}
span {line-height: 35px} is the reason for the big line spacing; and an absence of white-space: nowrap; is why it's breaking into lines. However, the main problem is that, when resized, there simply isn't enough space for all that stuff. This is due to the massive padding left and right of the .panel. Rather than use padding to position the item, you should try to arrange your nav items through floated divs, or text-align.
Set the min-width to something like:
.panel {
color: #6ab1ed;
padding: 0px 390px;
min-width: 160px;
}
Fiddle
.panel {
color: #6AB1ED;
padding: 0 350px;
width: 200px;
}
U can decide font size for different window size.Actually problem is when u resize size of text is remaining same and hence overflowing hence u can change below font-size: parameter according to ur need.This also works for mobile screen also.
#media all and (min-width: 400px) {
.panel {
font-size: 8px;
}
}
#media all and (min-width: 600px) {
.panel {
font-size: 16px;
}
}
Or
u can use jquery resize function for whole page refer this auto resize text (font size) when resizing window?
OR
Directly use inbuilt jQuery plugin like FitText (http://fittextjs.com/). It automatically sizes text to fit the width of the parent element.
Another jQuery plugin with the same goal is BigText(http://www.zachleat.com/web/bigtext-makes-text-big/).
DEMO bigtext
<div id="bigtext" style="width: 300px">
<div>The elusive</div>
<div>BIGTEXT</div>
<div>plugin exclusively</div>
<div>captured on film</div>
</div>
$('#bigtext').bigtext();
As u can see u just have to call a small function full implementation is in there website its just small snippet there are lot of use of that.
I have a div floating to the left of two text input elements. When I set margin-top on the inputs, the margin of the floating div is affected as well. Why is this, and how the F can I stop it from happening?!
Relevant HTML:
<body>
<div class="manage-page">
<h2>Set Logo Order</h2>
<hr>
<div class="logo-container">
<div class="logo-draggable">
<div class="logo-image-box"></div>
<input type="text" />
<input type="text" />
</div>
</div>
</div>
</body>
Relevant CSS:
.manage-page {
margin-top: 2.5em;
margin-left: 25%;
margin-right: 25%;
min-width: 50%;
}
.logo-container {
border:1px solid #777777;
clear: left;
cursor: move;
height: 12.5%;
margin-bottom: 0.625em;
}
.logo-image-box {
background-position: 50% 50%;
background-repeat: no-repeat;
background-size: contain;
border:1px solid #000000;
float: left;
height: 100%;
margin: 0 .875em;
width: 12.5%;
}
.logo-draggable input {
border: 1px solid #cccccc;
border-radius: 0.25em;
display: block;
font-size: 0.875em;
height: 2em;
line-height: 1.25;
margin-top: .5em;
padding: 0.375em 0.75em;
outline: none;
}
You can see it in action at the jsfiddle URL below. Just change the margin-top of .logo-draggable input and watch as the .logo-image-box gets bumped up/down as well:
http://jsfiddle.net/Uj2K6/
I think you suffer from collapsing margins (scroll down).
Vertical margins on different elements that touch each other (thus
have no content, padding, or borders separating them) will collapse,
forming a single margin that is equal to the greater of the adjoining
margins.
<div id="submitHolder">
<input type="submit" value="">
</div>
#submitHolder {
background-color: #FF0000;
line-height: 124px;
text-align: center;
}
input[type="submit"] {
background-image: url("http://icons.iconarchive.com/icons/hopstarter/button/256/Button-Next-icon.png");
background-position: 0 0;
background-repeat: no-repeat;
border: 0 none;
height: 44px;
width: 194px;
}
http://jsfiddle.net/BLPE7/4/
as you can see, it is precisely centered vertically with firefox, but not with chrome. How to solve it?
That problem seems to occur because your submit button has an empty value – looks like chrome messes something up with the line-height then. Once I give it a value, and if it’s even just a space character (and therefor still not visible), the problem disappears:
<input type="submit" value=" ">
http://jsfiddle.net/BLPE7/9/
You can also use padding. Check this out: http://jsfiddle.net/tDj2U/1/
#submitHolder {
background-color: #FF0000;
/*line-height: 124px;*/
padding: 40px 0;
text-align: center;
}
input[type="submit"] {
background-image: url("http://icons.iconarchive.com/icons/hopstarter/button/256/Button-Next-icon.png");
background-position: 0 0;
background-repeat: no-repeat;
border: 0 none;
height: 44px;
width: 194px;
}
Yes, there is such problem for chrome with big line-height values. I solve this problem in your case by adding position absolute/relative and margin centering:
#submitHolder {
background-color: #FF0000;
height: 124px;
text-align: center;
position: relative;
}
input[type="submit"] {
background-image: url("http://icons.iconarchive.com/icons/hopstarter/button/256/Button-Next-icon.png");
background-position: 0 0;
background-repeat: no-repeat;
border: 0 none;
height: 44px;
width: 194px;
position:absolute;
left: 50%;
top: 50%;
margin: -22px 0 0 -97px;
}
http://jsfiddle.net/BLPE7/11/
Add vertical-align:middle to your input control.