M
M
mtclwn2022-02-28 18:09:36
SQL
mtclwn, 2022-02-28 18:09:36

Why doesn't max-width="100%" work in the section description on the site (Bitrix)?

There are pictures in the text descriptions on the site. On mobile devices, they go off the screen, so I set the properties max-width="100%"; height="auto". And it works, but only on product pages. For some reason it's not on the page. What could be the problem? Or are there other ways to optimize images for mobile. devices?

An example of a page where properties work successfully is https://di-zel.ru/equipment/post_zapravki_konditsi...

An example of a page where max-width does not help is https://di-zel.ru/equipment/aircon/ (in description at the bottom of the page)

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dmitry Kovalsky, 2016-04-11
@dmitryKovalskiy

select name, MAX(price) from products 
GROUP BY name

But if you have the same products in the table under different ids with different prices, this is an architectural game that will generate hundreds of bugs.
UPD:
select name, MAX(id) from products 
GROUP BY name

Take away. but your solution is bad. You have one product, but there are many records on it. All the way you will stumble about finding out the actual id for this product, moreover, by indirect signs that are not indexes.

A
Alexey, 2016-04-11
@k1lex

Wrote you a test piece using RANK for your purposes

CREATE TABLE #products (
id int,
name nvarchar(255),
price money
)
insert into #products
(
id,
name,
price
)
values
(0,'пиво',100),(1,'водка',200),(2,'пиво',150),(3,'пиво',100),(4,'спирт',1000)


SELECT 
  id,
  name,
  price
FROM (
SELECT id
  ,NAME
  ,price
  ,RANK() OVER (PARTITION BY NAME ORDER BY ID DESC) RNK
FROM #products ) X
where X.RNK=1

E
Evgeny Bykov, 2016-04-11
@bizon2000

The standard straight-forward solution would be the following query:

SELECT t.name, (SELECT p.price FROM products p WHERE p.id = t.max_id) AS last_price
    FROM (SELECT name, max(id) AS max_id FROM products GROUP BY name) t

However, I highly recommend that you look into the previous solution (using RANK()) -- some problems simply cannot be solved without using this construct.

T
ThunderCat, 2022-02-28
@ThunderCat

An example of a page where properties work successfully
Does not work.
properties max-width="100%";
Firstly, this is not a "property" for you, but an attribute, and secondly, it does not work because such an attribute does not exist in the specification, if you want to set the maximum width, you need to use styles (and there it will still be a property).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question