javascript - Set the background size to 100% initially but ignore div expansion -


I have some problems with background-size: auto 100% my Inside the BTN -con class I know what is happening right below, there is no problem in it. When the button text is counted, a new line is created, which means that the icon should be increased to 100% of its new original height.

I need to change and change background-shaped behavior: auto 100% so that it initially its height to the original height of 100 %, But then if it was expanded due to a line break, then it remains exactly the same size, therefore not taking 100% height of the height of the new parents.

A clean, perfectly shaped icon:

Enter the image details here

Ugly icon:

 Enter image details here

HTML:

  & lt; A href = "#search"> & Lt; Div class = "button" & gt; & Lt; div class = "btn-icon" & gt; & Lt; / Div & gt; & Lt; Div class = "btn-lesson" & gt; & Lt; Div class = "title" & gt; Search & lt; / Div & gt; & Lt; Div class = "subtitle" & gt; Find things by typing things bla bla bla happy days: & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / A & gt;   

CSS:

 . Button {width: 100%; Box-size: border-box; Margin: 5 px 0; // font-family: arial, helvetica, sense-serif; Font-size: 14px; Color: #ffffff; Font size: 0.9 mm; Background color: # 0099 FAF; -max-boundary-radius: 5px; -WebKit-boundary-radius: 5px; Boundary-radius: 5px; Display: Table; Table-layout: Fixed; Padding: 2% 0; Height: 15%; } .btn-icon {display: table-cell; Width: 25%; Background: URL ("../img / icons / menu / search.png") Any repeat center center; Background-size: auto 100%; Box-size: border-box; } .btn-text {display: table-cell; Width: 75%; Padding: 5px 0; Box-size: border-box; } .btn-text .title {font-size: 1.05em; Font-weight: 400; } .btn-text .subtitle {font-size: 0.7em; Font-weight: 300; }    

Use jQuery on the top, mark the height of the icon 100% , And when you search that dynamic text to the div, just create an icon in the middle ( margin-top: 50%, above: - $ ('# icon'). Altitude () / 2 + 'px'

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -