CSS or jQuery on rails / How to “fill frame” with an image?
Tags: ruby-on-rails,css,image,scaling
Problem :
Whats the best technique for doing something like "fill frame" in indesign .. meaning take the image and scale the shortest side so it fits, then clipping the rest?
Is this possible with pure CSS ?
I am using Rails with jQuery..
The code could be something like this:
<div class="image_container"><img class="image" src=""></div>
Solution :
You can do it, if you had fixed size of image_container:
.image_container{
width:200px;
height:100px;
overflow:hidden;
}
.image_container img{width:200px;}
This will scale image by width and hide by height.
CSS Howto..
use display: table *{ padding: 0; margin: 0; box-sizing: border-box; } body { font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; font-weight: 300; } #menuBar {...
This depends on the elements inside of your li elements, but assuming you know what they are (in this case a): #nav li:hover a { color: inherit; } Though depending...
You need a different approach. Check out this url: http://www.eyecon.ro/colorpicker/. As you can see when you move slider up and down it changes the background of the picker div. But...
You can use height: 100% and vertical-align: top on img and on parent element use height: 100vh body, html { margin: 0; padding: 0; } div { display: inline-block; height:...
Specify a width, max-width, and min-width for the table cells, with the same value for all three properties.
You could use CSS filters: .sld-shadow { filter: blur(20px); } You'll want to make sure that you have browser support as well....
This can be achieved by dynamically adding/removing the class on loading and also while resizing the screen using Javascript/jQuery. The below sample uses jQuery but it can be ported back...
What you can do is use an extra container and position:absolute from the bottom, that way when you add more text the block seems to increase from bottom to top:...
The jQuery UI library makes it easy. The examples on that page show how to create a progress bar, and the "Methods" tab shows how to update the value.
As others have mentioned, using a CDN is usually as easy as adding: <link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet"> into your HTML. But this doesn't work when you are loading your html from...
You can use attribute equals selector $("[target=" + $(this).attr("target") + "]").css(/*propertyName [, propertyValue]*/) ...
In my personal experience, as i've done this for our platform, we generate the html as a regular page and then email it, taking care of using relative paths for...
I think the problem is the height. Try removing the 50% height and instead add padding of 50% .container > section > .content > .img{ display: block; width:100%; padding: 0...
refering to import .css file into .less file in your main.less: @import (css) "bootstrap_theme.css"; ...
I agree with everyone so far, in that there is no native CSS namespace capability and that if you have control (or the desire/capacity) to edit your HTML then that's...
Below is a sample of how you can do this. It is basically made with one parent div which has the ribbon text and two other div to produce the...
Hi this code is worked for me, check this: <ion-slide> <div class = "row"> <div class = "col col-50"> <img src="img/icon1.png"></img><br> Live Outlets </div> <div class = "col col-50"> <img...
Something like this should work: $('.hello').addClass('hint-auto-fade'); .hello { color: blue; } .hint-auto-fade { animation: autoFade 5s linear; } @keyframes autoFade { from { background: #ffe; color: #f00; } } <script...
I always use CSSLint for checking CSS errors CSS Lint...
As you are creating div with id #box, add the following css in the external css file and include it in the <head> #box { position: absolute; background: red; width:...
You can't disable the scroll for the page but you can disable the mousewheel event Edit: I do have to say that if you are running into this in the...
Ok, Try removing the runat="server" tag from the <head> tag
Try to keep things as short and simple as possible. Replace you scripting with the jquery code below where you simply check if the scrolling postion is off set: (function(...
<material-input floatingLabel style="width:250px"> or <material-input class="foo" floatingLabel> and material-input.foo { width: 250px; } ...
You can easily achieve this by using JQuery and ofcourse making some changes to your markup: HTML (remove the dropdown and use a bootstrap select box) <select id="selectbox"> <option value="#consumergoods">AppleBees</option>...
When you add style to your HTML code, or attach an external stylesheet using <link> in the <head> segment of your markup, the browser loads that resource for you. CSS...
Just do like this HTML <table style='width: 150px; border: 1px solid black;'> <tr> <td>blablabla</td> <td>blablabla</td> </tr> <tr> <td>abcd</td> <td>abcd</td> </tr> </table> CSS table { width:600px!important; border:1px solid black; } ...
You need to keep this as is: #breadcrumbs-two a::before{ content: ""; position: absolute; top: 50%; margin-top: -1.5em; border-width: 1.5em 0 1.5em 1em; border-style: solid; border-color: #ccc #ccc #ccc transparent; left:...
You can use :nth-child(n) selector to thicker some of your borders : DEMO as for a table , you can use these CSS rules : table { margin:1em auto; }...
Simplify your content: <div id="container"> <img src="http://placekitten.com/200/50"> <img src="http://placekitten.com/300/100"> <img src="http://placekitten.com/250/75"> </div> Then ensure the container has the same width as the largest contained image, and apply margin:0 auto; to...