There is a site in the central part of which there are product cards, which are flex containers.
// такой же код, что и код выше - только для черных пунктов меню типа Моноблоки
let categoryflag='';
$('.submenu__title a').on('click', function (event) {
event.preventDefault();
console.log('Inner check');
categoryflag=event.target.innerHTML;
subcategoryflag=categoryflag;
console.log(categoryflag);
$.ajax ({
method: 'POST',
url: '../php/ajaxsubcategory1.php',
cache: false,
data: {categoryflag: categoryflag, subcategoryflag: subcategoryflag},
dataType: 'json',
complete: function(data) {
console.log(data.header);
console.log(data.countrecords);
},
success: function (data) {
console.log('check');
console.log(data);
$('.rightmenu').html(data.result.msg);
let centeroutput='<div id=\"topcenterarea\">'+'<h1>'+data.result.header+' '+data.result.countrecords+' товара' + data.output[0]['screendiagonal'] + '</h1>'+'</div>';
productcardsoutput='';
// productcard='<div class="ProductCardBlock">';
for (let i=0; i<data.result.countrecords; i++)
{
productcard='<div class="ProductCardBlock">';
productcard+='<div class="ProductImage">';
productcard+='<div id="ImageWrapper">';
productcard+='<img class="ProductPicture" src='+'"../images/'+data.output[i]['imagepath']+'">';
productcard+='</div>';
productcard+='</div>';
productcard+='<div class="ProductDescription">';
productcard+='<div class="ProductName">' + data.output[i]['monoblockname'] +', ' + data.output[i]['color']+ '</div>';
productcard+='<div class="ProductScreenParams">'+ 'Диагональ/разрешение ' + data.output[i]['screendiagonal'] + '/' + data.output[i]['resolution'] + 'пикс.' +'</div>';
productcard+='<div class="ProductCpuType">'+ 'Тип процессора ' + data.output[i]['cputype'] +'</div>';
productcard+='<div class="ProductCpuFrequency">'+ 'Частота процессора ' + data.output[i]['frequency'] +'</div>';
productcard+='<div class="ProductRAM">' + 'Оперативная память (RAM) ' + data.output[i]['ramsize'] +'</div>';
productcard+='<div class="ProductVideoCard">' + 'Графический контроллер ' + data.output[i]['videocard'] +'</div>'
if (data.output[i]['memorytype']=='SSD') {
productcard+='<div class="ProductDisksAndDrives">' + 'Объем SSD ' + data.output[i]['sizememorydata'] +'</div>';
}
else if (data.output[i]['memorytype']=='HDD') {
productcard+='<div class="ProductDisksAndDrives">' + 'Объем HDD ' + data.output[i]['sizememorydata'] +'</div>';
};
productcard+='</div>';
productcard+='<div class="ProductBuyPart">'+ '<button type="submit" class="ProductAddToBasket" value="В корзину"></button>' +'</div>';
// productcard+='<div class="ProductScreenParams">'+ 'Диагональ/разрешение ' + data.output[i]['screendiagonal'] + '/' + data.output[i]['resolution'] + 'пикс.' +'</div>';
// productcard+='</div>';
// productcard+='</div>';
// productcard+='</div>';
// productcard+='</div>';
productcard+='</div>';
productcardsoutput+=productcard;
}
centeroutput+=productcardsoutput;
/*$('.centerarea').html('<div id=\"topcenterarea\">'+'<h1>'+data.header+' '+data.countrecords+' товара'+'</h1>'+'</div>');*/
$('.centerarea').html(centeroutput);
//expandCollapsedFunction();
}
}
);
}
);
.ProductCardBlock {
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
height: 311px;
}
.ProductCardBlock .ProductImage {
/*width: calc(191.5/931.75)*100%;*/
width: 10%;
height: 100%
}
.ProductCardBlock .ProductImage .ProductPicture {
margin-left: 15px;
margin-top: 20px;
margin-right: 5px;
}
.ProductCardBlock .ProductDescription {
width: 60%;
margin-top: 20px;
font: 14px Roboto, Tachoma, Arial, sans-serif;
}
.ProductCardBlock .ProductDescription .ProductName {
margin-bottom: 15px;
font: 16px Roboto, Tachoma, Arial,sans-serif;
}
.ProductCardBlock .ProductDescription .ProductScreenParams {
font: 14px Roboto, Tachoma, Arial,sans-serif;
padding-bottom: 5px;
margin-bottom: 0;
}
.ProductCardBlock .ProductDescription .ProductCpuType {
font: 14px Roboto, Tachoma, Arial,sans-serif;
margin-bottom: 5px;
}
.ProductCardBlock .ProductDescription .ProductCpuFrequency {
font: 14px Roboto, Tachoma, Arial,sans-serif;
margin-bottom: 5px;
}
.ProductCardBlock .ProductDescription .ProductRAM {
font: 14px Roboto, Tachoma, Arial,sans-serif;
margin-bottom: 5px;
}
.ProductCardBlock .ProductDescription .ProductVideoCard {
font: 14px Roboto, Tachoma, Arial,sans-serif;
margin-bottom: 5px;
}
.ProductCardBlock .ProductDescription .ProductDisksAndDrives {
font: 14px Roboto, Tachoma, Arial,sans-serif;
margin-bottom: 5px;
}
.ProductCardBlock .ProductBuyPart {
width: 30%;
}
.ProductCardBlock .ProductBuyPart .ProductAddToBasket {
margin: auto;
padding: 0;
}
There is a code that displays these flex containers (they consist of an image - ProductImage
, product characteristics - ProductDescription
and a button - ProductAddToBasket
, centered inside the ProductBuyPart
block).
As a result, I get the following page in the browser
Tell me how to get flex items to display correctly (some may have fixed widths). The picture should have 10% of the width of the product card, the description of the product - 60%, and the block with the button - 20%. (it is also possible to distribute the widths of the elements - 200px per picture, and for the product description and the button - 60% and 40% of the rest of the screen).
Aucun commentaire:
Enregistrer un commentaire