Certainly! To add the text "Laxmi | Saraswati | Durga" vertically (rotated at -90 degrees) to the left of your .content element, we'll modify your HTML structure and apply some CSS styling. Here's how you can achieve this:
1. Modify the HTML Structure
Add a new div with the class about-content-wrapper to wrap both your existing .content and the new vertical text. Here's the modified HTML:
<section id="about" class="about section light-background">
<div class="container">
<div class="about-content-wrapper">
<!-- Vertical Text -->
<div class="vertical-text">
Laxmi | Saraswati | Durga
</div>
<!-- Existing Content -->
<div class="content">
<div class="row justify-content-center">
<!-- Your existing columns and content -->
<div class="col-sm-12 col-md-5 col-lg-4 col-xl-4 order-lg-2 offset-xl-1 mb-4">
<!-- ... -->
</div>
<div class="offset-md-0 offset-lg-1 col-sm-12 col-md-5 col-lg-5 col-xl-4">
<!-- ... -->
</div>
</div>
</div>
</div>
</div>
</section>
2. Update Your CSS
Add the following CSS rules to style the new elements:
/* Wrapper for the content and vertical text */
.about .about-content-wrapper {
display: flex;
align-items: flex-start;
}
/* Style for the vertical text */
.about .vertical-text {
font-size: 18px;
white-space: nowrap; /* Prevent the text from wrapping */
margin-right: 20px; /* Space between text and content */
writing-mode: vertical-rl;
text-orientation: mixed;
transform: rotate(180deg); /* Flip the text vertically */
}
3. Ensure Responsiveness
We need to adjust the layout on smaller screens. Add media queries for responsiveness:
/* For screens wider than 768px */
@media (min-width: 768px) {
.about .about-content-wrapper {
flex-direction: row;
}
}
/* For screens smaller than 768px */
@media (max-width: 767px) {
.about .about-content-wrapper {
flex-direction: column;
align-items: center;
}
.about .vertical-text {
writing-mode: horizontal-tb;
transform: none;
margin-right: 0;
margin-bottom: 20px; /* Space below the text */
}
}
4. Explanation
-
HTML Changes:
- Added a new
<div class="about-content-wrapper"> to wrap .vertical-text and .content for proper flex layout.
- Inserted the vertical text within
<div class="vertical-text">.
-
CSS Styling:
- Flex Layout:
.about-content-wrapper uses display: flex to place the vertical text and content side by side.
- Vertical Text Styling:
writing-mode: vertical-rl; displays text vertically from top to bottom, right to left.
text-orientation: mixed; ensures the characters are upright, not rotated.
transform: rotate(180deg); flips the text for correct reading order.
white-space: nowrap; prevents the text from wrapping to new lines.
margin-right: 20px; adds space between the vertical text and the content.
-
Responsiveness:
- Large Screens: For screens wider than 768px, the layout is side by side.
- Small Screens: Below 768px, the layout switches to vertical (stacked).
- The vertical text changes to normal horizontal text using
writing-mode: horizontal-tb; and transform: none;.
- Adjusted margins to ensure proper spacing.
5. Enhancements and Cross-Browser Support
To ensure better cross-browser compatibility, include vendor prefixes:
.about .vertical-text {
/* Other styles... */
-webkit-writing-mode: vertical-rl;
-ms-writing-mode: tb-rl;
writing-mode: vertical-rl;
-webkit-text-orientation: mixed;
-ms-text-orientation: mixed;
text-orientation: mixed;
/* Other styles... */
}
6. Adjust the Content Width if Necessary
If the content area becomes too narrow due to the added vertical text, adjust the flex properties:
/* Allow content to take up remaining space */
.about .content {
flex-grow: 1;
}
7. Final CSS Code
Here is the complete CSS code for the new elements:
/* Wrapper for the content and vertical text */
.about .about-content-wrapper {
display: flex;
align-items: flex-start;
}
/* Style for the vertical text */
.about .vertical-text {
font-size: 18px;
white-space: nowrap;
margin-right: 20px;
/* Writing mode for vertical text */
-webkit-writing-mode: vertical-rl;
-ms-writing-mode: tb-rl;
writing-mode: vertical-rl;
-webkit-text-orientation: mixed;
-ms-text-orientation: mixed;
text-orientation: mixed;
transform: rotate(180deg);
}
/* Flex property for the content */
.about .content {
flex-grow: 1;
}
/* Responsiveness */
@media (min-width: 768px) {
.about .about-content-wrapper {
flex-direction: row;
}
}
@media (max-width: 767px) {
.about .about-content-wrapper {
flex-direction: column;
align-items: center;
}
.about .vertical-text {
margin-right: 0;
margin-bottom: 20px;
/* Reset writing mode */
-webkit-writing-mode: horizontal-tb;
-ms-writing-mode: lr-tb;
writing-mode: horizontal-tb;
transform: none;
}
}
8. Test Across Browsers and Devices
It's crucial to test the changes in different browsers (Chrome, Firefox, Safari, Edge) and on various devices to ensure consistent appearance.
9. Alternative Approach Using transform
If you prefer using transform for rotation, here's how you can do it:
CSS:
.about .vertical-text {
font-size: 18px;
white-space: nowrap;
margin-right: 20px;
transform: rotate(-90deg);
transform-origin: left top;
}
Explanation:
- This rotates the text -90 degrees.
transform-origin: left top; sets the point around which the rotation happens.
- Note that with this method, alignment and positioning can be a bit more complex, especially for responsive layouts.
However, using writing-mode is generally more efficient and produces cleaner results for vertical text.
10. Additional Styling
Feel free to style the vertical text further to match your site's theme:
.about .vertical-text {
color: var(--default-color);
font-weight: bold;
letter-spacing: 2px;
}
Summary
By following these steps, you'll have successfully added the vertical text "Laxmi | Saraswati | Durga" to the left of your .content element, with proper styling and responsiveness.
Let me know if you have any questions or need further assistance with this implementation!