<div class="card"> <img src="card-image.jpg" alt="会员卡图片"> <div class="card-content"> <h2>会员卡标题</h2> <p>会员卡描述信息</p> <a href="#" class="btn">立即加入</a> </div> </div>
<div>
element to create a container for the membership card. The <img alt="How to create a responsive membership card layout using HTML and CSS" >
element is used to display the picture of the membership card, and the <h2>
and <p>
elements are used to display the title and description of the membership card. Information, the <a>
element serves as a button to click to join the membership. <p>Next, we need to write CSS styles to achieve layout and responsive effects. The following is a basic CSS style example: .card { width: 300px; border: 1px solid #ccc; border-radius: 10px; overflow: hidden; margin: 20px; } .card img { width: 100%; height: auto; } .card-content { padding: 20px; } .card h2 { font-size: 20px; margin-bottom: 10px; } .card p { margin-bottom: 20px; } .card .btn { display: inline-block; padding: 10px 20px; background-color: #f44336; color: #fff; text-decoration: none; border-radius: 5px; } /* 响应式布局 */ @media screen and (max-width: 480px) { .card { width: 100%; margin: 10px 0; } .card-content { padding: 10px; } }
element, such as width, border , border radius and padding, etc. <img alt="How to create a responsive membership card layout using HTML and CSS" >
The width of the element is set to 100% to accommodate images of different sizes. The font size and margins are set in the <h2>
and <p>
elements. <p>Next, we added the CSS code for a responsive layout for small screen devices (max width 480px). In the responsive layout, we set the width of the membership card to 100% to make full use of the screen space. The padding of the membership card will also be adjusted appropriately to display better on small screen devices.
<p>With the above HTML structure and CSS style, we created a simple and practical responsive membership card layout. You can further modify and beautify it according to your needs and design style.
<p>I hope this article can be helpful to you when creating a responsive membership card layout using HTML and CSS. I wish you success in creating and achieving good results!
The above is the detailed content of How to create a responsive membership card layout using HTML and CSS. For more information, please follow other related articles on the PHP Chinese website!