You cannot sail with the wind opposite you. If the wind is following you, that is, directly astern, then you sail 'gull winged'.
No matter how hard you, as a sailor, wish the wind to blow, it is uncontrollable.
To sail against the wind, a boat has to 'tack'. This means that instead of sailing straight into the wind (which would get you nowhere) you sail in a zig-zag in the direction you intend to go. On each tack, the wind is on a different side of the sail.
Let's say the wind is coming at you from due North. Generally speaking, you cannot sail any closer to the wind than 45 degrees on either side of it's direction. So you could sail as close to the wind as 45 degrees on a starboard tack, or 315 degrees with your sails on a port tack.
Allegedly, the lateen sail design made it possible to sail closer into the wind. That is, less than 45 degrees from the direction the wind is blowing. No sail boat can sail directly into the wind. Yet.
The lateen sail increased a sailor's ability to sail effectively into the wind, rather than decreasing dependence on the wind's force. By allowing for better maneuverability and efficiency in changing wind conditions, the lateen sail revolutionized sailing techniques and made it easier to sail against the wind.
A three sided sail is known as a Lateen sail or also a triangular sail. With a four sided sail one is only able to sail against the wind, but with a Lateen sail it is possible to sail more directly into the wind.
No sailing ship can sail directly into the wind. However by rigging the sails correctly the vessel can be made to sail more closely to the wind.
Wut made ships sail in the wind was that using a persicet sail or flag will pick up the wind and will push the air out and sail..just like u swinging on a swing 
A boat can sail into the wind by sailing backwards and forwards (tacking) at an angle to the wind and so making her way up.
A sailing boat can not sail directly upwind, sail at about 45 degrees to the wind and tack (turn the boat through the wind) to the other side of the wind and continue in this zig-zag manner up wind.
The wind hitting the sail at an angle upwind pushes it sideways which is why you zigzag. Downwind wind hit sail straight on