-1

On the website I have I can only input code into the body and the footer.

The website is bothellhomes.com. The homepage shows three round images. On a mobile device, I want to resize the images so they show horizontally. Right now, since the images are so large, they go vertically.

Body code:

<section class="three-widgets">
<ul class="small-block-grid-1 medium-block-grid-3 text-center">
<li><a title="Advanced Search" href="/search/advanced_search/"><img src="https://u.realgeeks.media/lookinwa/advancedsearch.png" alt="Advanced Search" width="300" height="300" /></a></li>
<li><a title="Interactive Map Search" href="/map_search/results/9k/1/#/?city=Kenmore&city=Bothell&city=Kirkland&city=Woodinville&city=Bellevue&city=Lynnwood&city=Mill%20Creek&city=Redmond&page=1&list_price_max=800000&per_page=100&type=res&type=con&list_price_min=250000"><img src="https://u.realgeeks.media/lookinwa/mapsearch.png" alt="Interactive Map Search" width="300" height="300" /></a></li>
<li><a title="What's My Home Worth?" href="/cma/property-valuation/"><img src="https://u.realgeeks.media/lookinwa/homevaluation.png" alt="Home Value" width="300" height="300" /></a></li>
</ul>
</section>

Footer code:

<script>// <![CDATA[
document.write("<style>.three-widgets {margin-top: -60px;}.three-widgets img {background: #fff;border: 1px solid #ddd;border-radius: 100%;padding: 5px;}.three-widgets p {color: #000}.three-widgets li img {     opacity: .9;-webkit-transition: all 0.3s ease-out;     -moz-transition: all 0.3s ease-out;     -o-transition: all 0.3s ease-out;transition: all 0.3s ease-out;}.three-widgets li:hover img {border: 1px solid #444444;opacity: 1; -webkit-transform: scale(1.1);-moz-transform: scale(1.1);-ms-transform: scale(1.1);transform: scale(1.1);}@media (max-width:767px) {.three-widgets {     margin-top: 0}}h1{ line-height:38px!important}</style>");
// ]]></script>
j08691
  • 204,283
  • 31
  • 260
  • 272
  • 9
    Why aren't you using CSS and media queries instead of JavaScript? – j08691 Nov 17 '17 at 18:19
  • Exactly right about media queries, and also take a look at [this](https://stackoverflow.com/questions/19634463/what-is-an-srcset-attribute-in-img-tag-and-how-to-use-it) (Might be helpful too) – Alon Eitan Nov 17 '17 at 18:23
  • there are media queries in the footer code. How would I do what I am asking though? I've tried adding another media query for mobile sizes and it doesn't resize the images. – Kevin Boroumand Nov 17 '17 at 18:28
  • https://developer.mozilla.org/en-US/docs/Web/CSS/transform – jmargolisvt Nov 17 '17 at 18:42

2 Answers2

1

You should think mobile first. Apply styles to the images for the mobile version, and then override them using media queries for the desktop viewing.

You will likely want to add an ID or class to target strictly the desired images. In this case I added an id called round-images. Remove the classes "small-block-grid-1" and "medium-block-grid-3".

Body Code:

<section class="three-widgets" id="round-images">
<ul class="text-center">
<li><a title="Advanced Search" href="/search/advanced_search/"><img src="https://u.realgeeks.media/lookinwa/advancedsearch.png" alt="Advanced Search" width="300" height="300" /></a></li>
<li><a title="Interactive Map Search" href="/map_search/results/9k/1/#/?city=Kenmore&city=Bothell&city=Kirkland&city=Woodinville&city=Bellevue&city=Lynnwood&city=Mill%20Creek&city=Redmond&page=1&list_price_max=800000&per_page=100&type=res&type=con&list_price_min=250000"><img src="https://u.realgeeks.media/lookinwa/mapsearch.png" alt="Interactive Map Search" width="300" height="300" /></a></li>
<li><a title="What's My Home Worth?" href="/cma/property-valuation/"><img src="https://u.realgeeks.media/lookinwa/homevaluation.png" alt="Home Value" width="300" height="300" /></a></li>
</ul>
</section>

Next, style the images as you want for mobile using CSS. Since you don't have access to the header, you can get around that limitation through inline CSS or as I show below with embedded CSS. Lastly, add a media query to reset the styles how you had them before. Here is the idea:

<style>
/* the following controls image size */
#round-images img{
    max-width:100px;
    max-height:100px;
};
@media (min-width: 768px) {
    #round-images img{
        max-width:300px;
        max-height:300px;
    };
}
/* the following will remove the vertical stacking */
#round-images ul li{
    float:left;
    width:33%;
};
</style>

I got this working without your classes "small-block-grid-1 medium-block-grid-3".

Matt Lipman
  • 152
  • 1
  • 7
  • Thanks Matt for the help - this still doesn't work though. I embedded the code in the footer and it still shows vertically on mobile! – Kevin Boroumand Nov 17 '17 at 20:04
  • Would I have to add this CSS to the code in the body or the footer in a separate – Kevin Boroumand Nov 17 '17 at 20:17
  • No separate script needed. As long as the CSS code is placed anywhere in the html or html using style tags:, it should work. You also need to make sure you place id="round-images" in the
    tag. And lastly, remove class="small-block-grid-1 medium-block-grid-3" from your
      tag.
    – Matt Lipman Nov 17 '17 at 20:33
  • @kevin I updated the answer to show the complete code you may want to use. You likely can put both code blurbs in the **body code** section. – Matt Lipman Nov 17 '17 at 20:56
0

Not sure why you cannot use css. But it seems like you cannot so you can use inline styles to just float them next to each other. Keep in mind that it will become really small images the smaller the screen size is.

<li style="float:left;width="30%">

put this style on all the < li > elements. and the middle one should perhaps have 5% margin on each side to prevent the image edges from touching each other.

 <li style="float:left;width="30%;margin:0 5%;">

You also need to remove the height of the image and only set the width of the image to 100% so it will stretch to the edge of it's container which is the li.

You can of course do the same with css by giving the li's a class and floating them left.

Vaaljan
  • 691
  • 2
  • 10
  • 21
  • Check it out on the homepage: bothellhomes.com – Kevin Boroumand Nov 17 '17 at 20:14
  • The images when hovered over get bigger with the script from the footer. I'm not sure how to incorporate this code and have it clash with the code in the footer (see above). This didn't work for me for some reason. – Kevin Boroumand Nov 17 '17 at 20:15